Commits

Ruben Martinez-Cantin committed a18a3f9 Draft Merge
  • Participants
  • Parent commits 64440f5, 1a9d33a

Comments (0)

Files changed (29)

 3ef4cb03672d19a746a38771d1429a91f6f5595d v0.4
 3ef4cb03672d19a746a38771d1429a91f6f5595d v0.4
 0000000000000000000000000000000000000000 v0.4
+323dd8f1963e16c1a227b6e4cd7877933d352c17 v4.1
+323dd8f1963e16c1a227b6e4cd7877933d352c17 v4.1
+0000000000000000000000000000000000000000 v4.1
+4f88d930aee4d993ff8256586a5d811b1d9a3130 v0.4.1
 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
 # packages that should be included in the LaTeX output.
 
-EXTRA_PACKAGES         = amssymb
+EXTRA_PACKAGES         = amssymb amsmath
 
 # The LATEX_HEADER tag can be used to specify a personal LaTeX header for
 # the generated latex document. The header should contain everything until
 The online HTML version of these docs:
 <http://rmcantin.bitbucket.org/html/>
 
+- Download: <https://bitbucket.org/rmcantin/bayesopt>
+- Mirror: <https://github.com/rmcantin/bayesopt>
+
 Bayesian optimization uses a distribution over functions to build a
 metamodel of the unknown function for we are looking the extrema,
 and then apply some active learning strategy to select the query
   produce more advanced functions,
 - etc.
 
-Start by reading the \ref install and the \ref reference. You
-can also check about \ref bopttheory.
+The documentation can be found in:
 
-You can also find more details at:
-<http://bitbucket.org/rmcantin/bayesopt/wiki/Home>
+- [Install guide](http://rmcantin.bitbucket.org/html/install.html) and \ref install
+- [Reference manual](http://rmcantin.bitbucket.org/html/reference.html)  and \ref reference
+- [Bayesian optimization](http://rmcantin.bitbucket.org/html/bopttheory.html) and \ref bopttheory
+- [Models and functions](http://rmcantin.bitbucket.org/html/modelopt.html) and \ref modelopt
+- [Demos and examples](http://rmcantin.bitbucket.org/html/demos.html) and \ref demos
+- [Supported OS, compilers, versions...](https://bitbucket.org/rmcantin/bayesopt/wiki/Compatibility)
+
+You can also find more details at the [proyect
+wiki](http://bitbucket.org/rmcantin/bayesopt/wiki/Home) or subscribe
+to the [bayesopt-discussion mailing
+list](https://groups.google.com/forum/#!forum/bayesopt-discussion).
 
 **Important:** This code is free to use. However, if you are using the
 library, specially if it is for research or academic purposes, please

File app/bo_cont.cpp

   par.noise = DEFAULT_NOISE;
   par.surr_name = "sStudentTProcessJef";
   par.kernel.name = "kSum(kSEISO,kConst)";
-  par.mean.name = "mSum(mConst,mConst)";
+  par.mean.name = "mSum(mLinear,mConst)";
   par.l_type = L_ML;
   par.n_iterations = 200;       // Number of iterations
   par.n_init_samples = 50;

File app/bo_display.cpp

 using namespace bayesopt;
 
 int is_run=1;
+int is_step=0;
 size_t state_ii = 0;
 BayesOptBase* GLOBAL_MODEL;
 vector<double> lx,ly;
       double res = GLOBAL_MODEL->getSurrogateModel()->getLastSample(last);
       ly.push_back(res);
       lx.push_back(last(0));
+	  
+	  if (is_step) { is_run = 0; is_step = 0; }
     }
     
     int n=1000;
 void keyboard(unsigned char key, int x, int y){
     mp.keyboard(key, x, y); 
     if(key=='r'){ if(is_run==0){is_run=1;}else{is_run=0;}}
+	if(key=='s'){ is_run=1; is_step=1; } 
 }
 
 int main(int nargs, char *args[])
 {
   size_t dim = 1;
   bopt_params parameters = initialize_parameters_to_default();
-  parameters.n_init_samples = 10;
+  parameters.n_init_samples = 7;
   parameters.n_iter_relearn = 0;
   parameters.n_iterations = 300;
-  //parameters.surr_name = "sStudentTProcessNIG";
+  parameters.verbose_level = 2;
+
+  // Surrogate models
+  //  parameters.surr_name = "sStudentTProcessNIG";
   parameters.surr_name = "sGaussianProcessNormal";
 
-  parameters.crit_name = "cLCB";
-  parameters.crit_params[0] = 5;
+  // Criterion model
+  // parameters.crit_name = "cAopt";
+  // parameters.n_crit_params = 0;
+
+  parameters.crit_name = "cEI";
+  parameters.crit_params[0] = 1;
   parameters.n_crit_params = 1;
 
-  parameters.kernel.name = "kSum(kPoly3,kRQISO)";
+  // parameters.crit_name = "cLCB";
+  // parameters.crit_params[0] = 5;
+  // parameters.n_crit_params = 1;
+
+  // Kernel models
+  // parameters.kernel.name = "kSum(kPoly3,kRQISO)";
+  // double mean[128] = {1, 1, 1, 1};
+  // double std[128] = {10, 10, 10, 10};
+  // size_t nhp = 4;
+  // memcpy(parameters.kernel.hp_mean, mean, nhp * sizeof(double));
+  // memcpy(parameters.kernel.hp_std,std, nhp * sizeof(double));
+  // parameters.kernel.n_hp = nhp;
+
+  parameters.kernel.name = "kMaternISO3";
   parameters.kernel.hp_mean[0] = 1;
-  parameters.kernel.hp_mean[1] = 1;
-  parameters.kernel.hp_mean[2] = 1;
-  parameters.kernel.hp_mean[3] = 1;
   parameters.kernel.hp_std[0] = 5;
-  parameters.kernel.hp_std[1] = 5;
-  parameters.kernel.hp_std[2] = 5;
-  parameters.kernel.hp_std[3] = 5;
-  parameters.kernel.n_hp = 4;
+  parameters.kernel.n_hp = 1;
 
-  parameters.verbose_level = 2;
+
 
   state_ii = 0;
 

File bin/testmatlab.c

-#include "mex.h"
-
-
-void mexFunction( int nlhs, mxArray *plhs[],
-                  int nrhs, const mxArray *prhs[])
-{
-    mwSize mrows,mcols;
-    char *name;
-    double *x,*y;
-    mxArray *rhs[1], *lhs[1];
-    
-    /* check for proper number of arguments */
-    if(nrhs!=2) 
-      mexErrMsgTxt("Two input required.");
-    else if(nlhs > 1) 
-      mexErrMsgTxt("One output arguments.");
-    
-    /* check to make sure the first input argument is a scalar */
-    mrows = mxGetM(prhs[0]);
-    mcols = mxGetN(prhs[0]);
-    if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) ||
-          mrows*mcols!=1 ) {
-        mexErrMsgTxt("Input x must be a scalar.");
-    }
-  
-    /*  get the scalar input x */
-    //x = mxGetScalar(prhs[0]);
-
-    /* input must be a string */
-    if ( mxIsChar(prhs[1]) != 1)
-      mexErrMsgTxt("Input must be a string.");
-
-    /* input must be a row vector */
-    if (mxGetM(prhs[1])!=1)
-      mexErrMsgTxt("Input must be a row vector.");
-    
-    /* copy the string data from prhs[0] into a C string input_ buf.    */
-    name= mxArrayToString(prhs[1]);
-    
-    if(name == NULL) 
-      mexErrMsgTxt("Could not convert input to string.");
-    
-    mexCallMATLAB(nlhs, plhs, 1, prhs, name);
-
-    //plhs[0] = mxCreateDoubleMatrix(mrows,ncols, mxREAL);
-
-    mxFree(name);
-    return;
-}
-

File doxygen/contribute.dox

+/*!  \page contriblib Contribute to the library
+\tableofcontents
+
+\section addcomp Adding components
+
+Thanks to the modular design, adding new components is very easy. Most
+of the inner functions (kernels, criteria, etc.) are designed as
+functors (function objects). Thus, we just need to inherit from the
+interface (abstract) functor or one of the existing functions. The new
+functor would be automatically integrated, including advanced usage
+(for example: annealing).
+
+Although it would be more efficient to use a template system. The
+functors are instantiated dynamically using a factory model. This
+allows changes without recompiling the library, which is specially
+important while using dynamic languages (Python, Matlab, etc.).
+
+\subsection addfunct Adding functors (kernels, criteria and mean functions)
+
+The three elements follow the same structure. The interface (abstract
+class) and the factory model are defined in the \c *_functors.hpp and
+\c *_functors.cpp files, respectively.
+
+Then, there are two types of functors: atomic and combined. Atomic
+functors are used to define directly a function (e.g.: a Gaussian
+kernel) and they return a value. Combined functors are used to combine
+2 or more functors (e.g.: sum of kernels), which can be atomic or
+combined (e.g.: a sum of products of kernels).
+
+Combined kernels and mean functions only allows binary expressions -2
+elements- while combined criteria support any number of elements (see
+cHedge function in \ref combcri).
+
+Finally, add the corresponding register with the new function name in
+the Factory model in \c *_functors.cpp
+
+\section modpy Modifying the Python interface:
+
+Read this part <B>only if you need to modify</B> the Python interface.
+
+\subsection instcython Install Cython:
+
+First, you need to install Cython:
+
+In \b Ubuntu/Debian, you can get it by running:
+\verbatim
+>> sudo apt-get install cython
+\endverbatim
+
+In \b MacOS you can install macports and run:
+\verbatim
+>> sudo port install py27-cython
+\endverbatim
+
+Or we can download it from the website: http://cython.org 
+
+\subsection modcython Working with Cython:
+
+The interface is defined in \c python/bayesopt.pyx file, which is
+written in Cython, a mixture of C and Python code. For more
+information, check the online documentation http://docs.cython.org/
+
+Then, you need to run the Cython compiler.
+
+\verbatim
+$ cython --cplus bayesopt.pyx
+\endverbatim
+
+which generates the file \c python/bayesopt.cpp, which can be directly
+used in the library. Python would only find the library if it is
+called exactly \c bayesopt.so
+
+*/

File doxygen/demos.dox

+/*! \page demos Description of demo files
+\tableofcontents
+
+We have include a descriptions of the different demos than can be found in the
+library. Most of them are used to highlight the capabilities of the Bayesian optimization
+framework or the characteristics of the library.
+
+\b Important: note that some demos requires some extra dependencies to work (OpenGL, SimpleCV, etc.)
+
+\section cppdemos C/C++ demos
+
+These demos are automatically compiled and installed with the library. They can be found in the \c /bin subfolder. The source code of these demos is in \c /app
+
+\subsection quadcpp Interface test (continuous and discrete)
+
+\b bo_cont and \b bo_disc provides examples of the C (callback) and C++ (inheritance) interfaces for a simple quadratic function. They are the best starting point to start playing with the library.
+
+\subsection onedcpp 1D test
+
+\b bo_oned deals with a more interesting, yet simple, multimodal 1D function. \b bo_display shows the same example, but includes a visualization tool (requires OpenGL and FreeGLUT).
+
+\image html doxygen/oned.jpg
+
+\subsection brcpp Branin test
+
+\b bo_branin shows the a 2D example with the Branin function, which is a standard function to evaluate nonlinear optimization algorithms.
+
+\f[
+f(x,y) = \left(y-\frac{5.1}{4\pi^2}x^2 + \frac{5}{\pi}x-6\right)^2 + 10\left(1-\frac{1}{8\pi}\right) \cos(x) + 10
+\f]
+
+with a search domain \f$−5 \leq x \leq 10\f$, \f$0 \leq y \leq 15\f$.
+
+\image html doxygen/branin.jpg
+
+The function has three global minimum. The position of those points (after normalization to the [0,1] plane) are:
+
+\f{align*}{
+x &= 0.1239, y = 0.8183\\
+x &= 0.5428, y = 0.1517\\
+x &= 0.9617, y = 0.1650
+\f}
+
+\section pydemos Python demos
+
+These demos use the Python interface of the library. They can be found in the \c /python subfolder.
+
+Make sure that the interface has been generated and that it can be found in the corresponding path (i.e. PYTHONPATH).
+
+\subsection pyapidemo Interface test
+
+\b demo_quad provides an simple example (quadratic function). It shows the continuous and discrete cases and it also compares the callback and inheritance interfaces. It is the best starting point to start playing with the Python interface.
+
+\b demo_dimscaling shows a 20D quadratic function with different smoothness in each dimension. It also show the speed of the library for <em>high dimensional functions</em>.
+
+\b demo_distance is equivalent to the demo_quad example, but it includes a penalty term with respect to the distance between the current and previous sample. For example, it can be used to model sampling strategies which includes a mobile agent, like a robotic sensor as seen in \cite Marchant2012.
+
+\subsection pyproc Multiprocess demo
+
+\b demo_multiprocess is a simple example that combines BayesOpt with the brilliant multiprocessing library. It shows how simple BayesOpt can be used in a parallelized setup, where one process is dedicated for the BayesOpt and the rests are dedicated to function evaluations.
+
+\subsection pycam Computer Vision demo
+
+\b demo_cam is a demonstration of the potetial of BayesOpt for parameter tuning. The advantage of using BayesOpt versus traditional strategies is that it only requires knowledge of the <em>desired behavior</em>, while traditional methods for parameter tuning requires deep knowledge of the algorithm and the meaning of the parameters.
+
+In this case, it takes a simple example (image binarization) and show how a simple behavior (balanced white/black result) matches the result of the adaptive thresholding from Otsu's method -default in SimpleCV-. Besides, it find the optimal with few samples (typically between 10 and 20)
+
+demo_cam requires SimpleCV and a webcam.
+
+\section matdemos MATLAB/Octave demos
+
+These demos use the Matlab interface of the library. They can be found in the \c /matlab subfolder.
+
+Make sure that the interface has been generated. If the library has been generated as a shared library, make sure that it can be found in the corresponding path (i.e. LD_LIBRARY_PATH in Linux/MacOS) before running MATLAB/Octave.
+
+\subsection matapidemo Interface test
+
+\b runtest shows the discrete and continuous interface. The objective function can be selected among all the functions defined in the \c /matlab/testfunctions subfolder, which includes a selection of standard test functions for nonlinear optimization:
+
+- Quadratic function
+- Branin
+- Langermann
+- Michaelewicz
+- Rosenbrock
+
+\subsection reembodemo Demo in very high dimensions
+
+\b demo_rembo evaluates the REMBO (Random EMbedding Bayesian
+Optimization) algorithm for optimization in very high dimensions. The
+idea is that Bayesian optimization can be used very high dimensions
+provided that the effective dimension is embedded in a lower space, by
+using random projections.
+
+In this case, we test it against an artificially augmented Branin
+function with 1000 dimensions where only 2 dimensions are actually
+relevant (but unknown). The function is defined in the file: 
+\c braninghighdim
+
+For details about REMBO, see \cite ZiyuWang2013.
+
+*/

File doxygen/install.dox

 BayesOpt uses standard C/C++ code (C++98) and it can be compiled in
 different platforms and used from different languages.
 
-\section instc Install C/C++ library:
+\section unixinst Installing in Linux/MacOS:
+
+The compilation is very similar in any *nix system. Note that the
+Python or Matlab interfaces are not included by default.
+
+\subsection getDepend Getting dependencies:
 
 The easiest way to compile this library is using the cross platform
 and cross compiler tool <a href="http://www.cmake.org/">CMake</a>.
 
 This code uses Boost libraries for matrix operations (uBlas), random
-number generation, math functions and smart pointer. They can be found
-in many Linux and MacOS repositories. It can also be downloaded from
-http://www.boost.org.
+number generation, math functions and smart pointers. Being only
+include files, Boost does not require any speciall install. Boost can
+be found in many Linux and MacOS repositories. It can also be
+downloaded from http://www.boost.org.
 
-\subsection cinlinux Linux:
-For Ubuntu/Debian, the minimum dependencies can be optained by running:
+Both Python development files (Python.h) and Numpy are needed if you
+want the Python interface. The library has been tested with Python 2.6
+and 2.7. The interface relies on Numpy arrays.
+
+Finally, if you want the Matlab interface, just make sure your C++
+compiler is compatible with your Matlab version.
+
+\subsubsection cinlinux Linux:
+For Ubuntu/Debian, the minimum dependencies (C/C++) can be optained by running:
 \verbatim
->> sudo apt-get install libboost-dev cmake g++
+>> sudo apt-get install libboost-dev cmake cmake-curses-gui g++
+\endverbatim
+
+If you want the Python interface:
+\verbatim
+>> sudo apt-get install python-dev python-numpy
+\endverbatim
+
+If you want the Octave interface:
+\verbatim
+>> sudo apt-get install octave-headers
 \endverbatim
 
 And for all dependencies:
 \verbatim
->> sudo apt-get install libboost-dev python-dev python-numpy cmake g++ cython octave-headers
+>> sudo apt-get install libboost-dev python-dev python-numpy cmake cmake-curses-gui g++ cython octave-headers
 \endverbatim
 
-\subsection cinmac MacOS:
-There are many options. For example, you can install macports and run:
+\subsubsection cinmac MacOS:
+This section assumes \b macports is installed. Similar packages can be
+found in \b fink or \b homebrew. For the minimal install, run:
 \verbatim
 >> sudo port install boost gcc46 cmake
 \endverbatim
 
-Again, for full dependencies:
+If you want the Python interface:
+\verbatim
+>> sudo port install python27 py27-numpy
+\endverbatim
+
+If you want the Octave interface:
+\verbatim
+>> sudo port install octave
+\endverbatim
+
+Again, for all dependencies:
 \verbatim
 >> sudo port install boost python27 py27-numpy gcc46 cmake py27-cython octave
 \endverbatim
 
-\subsection compile Compile in Linux or MacOS:
+
+\subsection compile Compile the library:
 In order to compile the source code in a *nix system, run this from a terminal.
 \verbatim
 >> cmake . 
 >> sudo make install
 \endverbatim
 
-If you use \em ccmake instead of \em cmake you will access a graphical
-interface to select features such as debug/release mode and if you
-want to use shared libraries or not. Shared libraries are required to
-run the Python interface.
+\b Important: If you use \b ccmake instead of \b cmake you will access a graphical
+interface to select features such as the include the Python and Matlab
+interfaces, debug/release mode or if you want to use shared libraries
+or not. \b Shared libraries are required to run the Python interface.
+
+
+\subsubsection docbuild Building the documentation
 
 If you have doxygen installed on your computer, you can compile the
 documentation right after compiling the code by running.
 \endverbatim
 Thid documentation will appear in the "doc" subdirectory.
 
-\subsection cinwin Windows and other systems:
+\subsection instpython Python interface:
+
+Both Python development files (Python.h) and Numpy are needed if you
+want the python interface. The library has been tested with Python 2.6
+and 2.7. The interface relies on Numpy arrays. If we want to select
+the option to compile the Python interface we can just run:
+\verbatim
+>> ccmake . 
+>> make
+>> sudo make install
+\endverbatim
+
+\b Important: Python requires bayesopt to be a \b shared library.
+
+\subsection instmatlab MATLAB/Octave interface:
+
+Make sure the library is compiled with the MATLAB_COMPATIBLE option
+using ccmake and configure Matlab/Octave to compile mex files. For
+example, in Matlab you can run to check the supported compilers:
+\verbatim
+>> mex -setup
+\endverbatim
+
+Run the corresponding script compile_matlab.m or compile_octave.m,
+which can be found in the \em /matlab/ directory.
+
+If bayesopt or nlopt are compiled as \b shared libraries, then, at run
+time, MATLAB/Octave also needs to access to the libraries. For
+example, LD_LIBRARY_PATH must include the folder where the libraries
+are. If the install path is the default, you can execute the
+exportlocalpath.sh script before calling MATLAB.
+
+
+
+<HR>
+
+\section cinwin Windows and other systems:
 Install this components:
 \li CMake: http://www.cmake.org
+
+CMake for Windows provides a nice GUI where you can select your
+favorite C++ compiler (MinGW, Visual Studio, etc.). It will
+automatically create the necesary configuration files for the compiler
+(makefile, solution, etc.).
+
 \li Boost: http://www.boost.org
-\li MinGW: http://www.mingw.org
-
-MinGW can be replaced by your favorite C++ compiler (Visual Studio,
-Intel, etc.).
 
 Since Boost they are pure template libraries, they do not require
 compilation. Just make sure the headers are on the include path. You
 can also add an entry named BOOST_ROOT in CMake with the corresponding
 path to the library.
 
-<HR>
+\li MinGW: http://www.mingw.org
 
-\section instpython Install Python interface:
-
-Both Python and Numpy are needed if you want the python interface. The
-library has been tested with Python 2.6 and 2.7. The interface relies
-on Numpy arrays. Python development files such as Python.h are needed
-to compile the interface.
-
-In \b Ubuntu/Debian, you can get the dependencies by running:
+If you do not have a C++ compiler, we recomend MinGW+MSYS. Then, you
+just need to compile from the command line with:
 \verbatim
->> sudo apt-get install python-dev python-numpy cython
+>> mingw32-make
 \endverbatim
 
-In \b MacOS you can install macports and run:
+\subsection instpythonwin Python interface:
+
+The Python interface has not been tested in \b Windows because getting
+the correct dependencies is highly involved. You might need to
+download and install:
+\li Python (binary and \b sources): http://www.python.org
+\li Numpy: http://new.scipy.org/download.html 
+
+Also, read this article about how to link everything:
+http://docs.python.org/2/extending/windows.html#building-on-windows
+
+
+\subsection instmatlabwin MATLAB/Octave interface:
+
+Make sure the library is compiled with the MATLAB_COMPATIBLE option
+and configure Matlab/Octave to compile mex files. For example, in
+Matlab you can run to check the supported compilers:
 \verbatim
->> sudo port install python27 py27-numpy py27-cython
+>> mex -setup
 \endverbatim
 
-It you want to \b modify the Python interface, you need to modify the
-pyx file and run the Cython compiler.
-
-\verbatim
-$ cython --cplus bayesopt.pyx
-\endverbatim
-
-\b Important: Python requires bayesopt to be a \b shared library.
-
-In \b Windows you might need to download and install:
-\li Python: http://www.python.org
-\li Numpy: http://new.scipy.org/download.html 
-\li Cython: http://cython.org 
-
-Make sure that CMake finds all the dependencies.
-
-<HR>
-
-\section instmatlab Install MATLAB/Octave interface
-
-Make sure the library is compiled with the MATLAB_COMPATIBLE option.
-
-Compile the interface using the compile_matlab.m or compile_octave.m
-script, which can be found in the \em /matlab/ directory.
+Run the corresponding script compile_matlab.m or compile_octave.m,
+which can be found in the \em /matlab/ directory. 
 
 If bayesopt or nlopt are compiled as \b shared libraries, then, at run
-time, MATLAB/Octave also needs to access to the libraries. For
-example, in Linux and Mac OS you make sure to execute the
-exportlocalpath.sh script is executed before calling MATLAB.
+time, MATLAB/Octave also needs to access to the libraries. You can
+modify the PATH variable or copy the dll files in the same bolder as
+the generated mexfile.
+
 
  */

File doxygen/introduction.dox

 \f]
 where
 \f[
-  \epsilon(\mathbf{x}) \sim \mathcal{NP} \left( 0, \sigma^2_s (\mathbf{K}(\theta) + \sigma^2_n \I) \right)
+  \epsilon(\mathbf{x}) \sim \mathcal{NP} \left( 0, \sigma^2_s (\mathbf{K}(\theta) + \sigma^2_n \mathbf{I}) \right)
 \f]
 The term \f$\mathcal{NP}\f$ means a non-parametric process, which can
 make reference to a Gaussian process \f$\mathcal{GP}\f$ or a Student's

File doxygen/reference.dox

 
 \subsection pyusage Python callback/inheritance usage
 
-The file python/test.py provides examples of the two Python
+The file python/demo_quad.py provides examples of the two Python
 interfaces.
 
 \b Parameters: For both interfaces, the parameters are defined as a

File include/criteria_atomic.hpp

     int setParameters(const vectord &params) { return 0; };
     size_t nParameters() {return 0;};
     double operator()( const vectord &x)
-    { return mProc->prediction(x)->getStd(); };
+    { return -mProc->prediction(x)->getStd(); };
     std::string name() {return "cAopt";};
   };
 

File include/parameters.h

   /*************************************************************/
   /* These functions are added to simplify wrapping code       */
   /*************************************************************/
-  surrogate_name str2surrogate (const char* name);
+  /* surrogate_name str2surrogate (const char* name); */
   learning_type  str2learn     (const char* name);
 
-  BAYESOPT_API const char* surrogate2str(surrogate_name name);
+  /* BAYESOPT_API const char* surrogate2str(surrogate_name name); */
   BAYESOPT_API const char* learn2str(learning_type name);
 
   BAYESOPT_API bopt_params initialize_parameters_to_default(void);

File matlab/bayesopt.m

 %        [xmin, fmin] = bayesoptdisc('function_name', validset, params)
 %
 %
-% nDimensions is the number of dimensions of the query vector.
+% nDimensions is the number of dimensions (d) of the query vector.
 %
 % Params is a struct which have the same fields as the C/C++ interface 
 %   (see include/parameters.h)
 %
-% lowerBound and upperBound should be a nDim x 1 or 1 x nDim vectors with
+% lowerBound and upperBound should be a d x 1 or 1 x d vectors with
 %      the lower and upper bound for each component. (optional, default 0-1)
 %
-% validset is the set of discrete points for discrete optimization
+% validset is the set of discrete points for discrete optimization,
+%      stacked in a single matrix. Thus, it must be a d x n matrix.
 %
 % 
 % -------------------------------------------------------------------------

File matlab/bayesoptextras.h

 static void struct_string(const mxArray *s, const char *name, char* result)
 {
   mxArray *val = mxGetField(s, 0, name);
+  char *valstr;
 
   if (val) {
     if( mxIsChar(val) ) {
-      result = mxArrayToString(val);
+      if ( mxGetString(val, result, 1+(mxGetM(val) * mxGetN(val)))) {
+	  mexErrMsgTxt("Error loading string.");
+	}
     } else {
       mexErrMsgTxt("Method name must be a string");
     }

File matlab/demo_rembo.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+clear all, close all
+addpath('testfunctions')
+
+params.n_iterations = 300;
+params.n_init_iterations = 50;
+params.crit_name = 'cEI';
+params.surr_name = 'sGaussianProcessNormal';
+params.noise = 0.005;
+params.kernel_name = 'kMaternISO3';
+params.kernel_hp_mean = [0.5];
+params.kernel_hp_std = [10];
+params.verbose_level = 0;
+params.log_filename = 'matbopt.log';
+
+n = 2;          % number of low dims (effective)
+nh = 1000;      % number of actual dims
+nreembo = 10;    % number of reembo iterations
+
+
+global MATRIX_A
+global truei
+
+truei = [150,237];
+
+lb = ones(n,1)*-sqrt(n);
+ub = ones(n,1)*sqrt(n);
+fun = 'braninhighdim';    % the function has an effective 2D
+values = zeros(nreembo,1);
+points = zeros(nreembo,n);
+
+for i=1:nreembo
+    disp('Continuous optimization');
+    MATRIX_A = randn(nh,n);
+    tic;
+    result = bayesopt(fun,n,params,lb,ub);
+    toc;
+
+    values(i) = braninhighdim(result);
+    hd_res = MATRIX_A*result';
+    points(i,:) = hd_res(truei)';
+    disp(hd_res(truei)); disp(values(i));
+end;
+
+[foo,id] = min(values);
+disp(points(id,:));

File matlab/runtest.m

 params.n_iterations = 100;
 params.n_init_iterations = 50;
 params.crit_name = 'cEI';
-params.surr_name = 'GAUSSIAN_PROCESS';
+params.surr_name = 'sGaussianProcessNormal';
 params.noise = 0.005;
 params.kernel_name = 'kMaternISO3';
 params.kernel_hp_mean = [0.5];
 params.kernel_hp_std = [10];
-params.verbose_level = 1;
+params.verbose_level = 0;
 params.log_filename = 'matbopt.log';
 
-n = 5;
+% n = 5;
+% lb = ones(n,1)*pi/2;
+% ub = ones(n,1)*pi;
+% fun = 'michalewicz';
 
-lb = ones(n,1)*pi/2;
-ub = ones(n,1)*pi;
-fun = 'michalewicz';
+n = 2;
+lb = zeros(n,1);
+ub = ones(n,1);
+fun = 'branin';
 
 disp('Continuous optimization');
 tic;

File matlab/testfunctions/ackley.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
 function y = ackley(x)
 % Bounds -32.768, 32.768
 % Min x = zeros, y = 0

File matlab/testfunctions/branin.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
+function y = branin(x)
+%Bounds [0,1]^2
+% Min = 0.1239 0.8183
+% Min = 0.5428 0.1517  => 0.3979
+% Min = 0.9617 0.1650
+    
+a = x(1) * 15 - 5;
+b = x(2) * 15;
+
+y = (b-(5.1/(4*pi^2))*a^2+5*a/pi-6)^2+10*(1-1/(8*pi))*cos(a)+10;

File matlab/testfunctions/braninhighdim.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
+function y = branin(x)
+%Bounds [0,1]^2
+% Min = 0.1239 0.8183
+% Min = 0.5428 0.1517  => 0.3979
+% Min = 0.9617 0.1650
+
+global MATRIX_A
+global truei
+
+z = MATRIX_A*x';
+
+if (z(truei(1)) < 0) z(truei(1)) = 0; end;
+if (z(truei(2)) < 0) z(truei(2)) = 0; end;
+if (z(truei(1)) > 1) z(truei(1)) = 1; end;
+if (z(truei(2)) > 1) z(truei(2)) = 1; end;
+
+% Trick: We assume the function has 1000 dims, but in reality, it is just
+% the traditional 2D branin.
+
+a = z(truei(1)) * 15 - 5;
+b = z(truei(2)) * 15;
+
+y = (b-(5.1/(4*pi^2))*a^2+5*a/pi-6)^2+10*(1-1/(8*pi))*cos(a)+10;

File matlab/testfunctions/langermann.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
 function x_out = langermann(x_in)
 % Bounds [3,5]
     a = [3,5,2,1,7];

File matlab/testfunctions/michalewicz.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
 function y = michalewicz(x)
 %Bounds [0,pi]
 %Min = -4687 (n=5)

File matlab/testfunctions/quadratic.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
 function [value] = quadratic(xin)
 % Simple quadratic function [0,1]
     xin = xin - 0.53;

File matlab/testfunctions/rosenbrock.m

+% 
+% -------------------------------------------------------------------------
+%    This file is part of BayesOpt, an efficient C++ library for 
+%    Bayesian optimization.
+%
+%    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+%
+%    BayesOpt is free software: you can redistribute it and/or modify it 
+%    under the terms of the GNU General Public License as published by
+%    the Free Software Foundation, either version 3 of the License, or
+%    (at your option) any later version.
+%
+%    BayesOpt is distributed in the hope that it will be useful, but 
+%    WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU General Public License for more details.
+%
+%    You should have received a copy of the GNU General Public License
+%    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+% ------------------------------------------------------------------------
+%
+
 function y = rosenbrock(x)
 % Bounds [-2.048,2.048]
 % Min y = 0

File optimization.bib

   title = {Bayesian Approach to Global Optimization},
   publisher = {Kluwer Academic Publishers},
   year = {1989},
-  editor = {Michiel HazewinkeI},
   author = {Mockus, Jonas},
   volume = {37},
   series = {Mathematics and Its Applications},
   timestamp = {2010.06.18}
 }
 
-@ARTICLE{O'Hagan1992,
+@ARTICLE{OHagan1992,
   author = {Anthony O'Hagan},
   title = {Some {B}ayesian Numerical Analysis},
   journal = {Bayesian Statistics},

File python/demo_dimscaling.py

 params['n_init_samples'] = 150
 #params['noise'] = 0.01
 #params['kernel_name'] = "kMaternISO3"
-params['surr_name'] = "STUDENT_T_PROCESS_NORMAL_INV_GAMMA"
+params['surr_name'] = "sStudentTProcessJef"
 
 dim = 20
 lb = np.ones((dim,))*0

File python/demo_multiprocess.py

     bo = BayesOptProcess(pipe_child)
     bo.params['n_iterations'] = 50
     bo.params['n_init_samples'] = 20
-    bo.params['s_name'] = "GAUSSIAN_PROCESS_INV_GAMMA_NORMAL"
-    bo.params['c_name'] = "GP_HEDGE"
+    bo.params['s_name'] = "sGaussianProcessNormal"
+    bo.params['c_name'] = "cHedge(cEI,cLCB,cExpReturn,cOptimisticSampling)"
 
     p = Process(target=worker, args=(pipe_par,))
 

File src/parameters.cpp

 
 
 
-surrogate_name str2surrogate(const char* name)
+/*surrogate_name str2surrogate(const char* name)
 {
   if      (!strcmp(name,  "GAUSSIAN_PROCESS"))
     return S_GAUSSIAN_PROCESS;
     case S_ERROR:
     default: return "ERROR!";
     }
-}
+    }*/
 
 
 learning_type str2learn(const char* name)
 
 
 char DEF_LOG_FILE[] = "bayesopt.log";
-char DEF_SUR_NAME[] = "GAUSSIAN_PROCESS";
+char DEF_SUR_NAME[] = "sGaussianProcess";
 char DEF_KERNEL_NAME[] = "kMaternISO3";
 char DEF_MEAN_NAME[] = "mOne";
 char DEF_CRITERIA_NAME[] = "cEI";

File utils/log.hpp

 
 /** \file log.hpp 
     \brief Modules and helper macros for logging. */
-/* 
-   Original file obtained from:
-   Logging In C++
-   By Petru Marginean, September 05, 2007
-   http://www.drdobbs.com/cpp/logging-in-c/201804215
-*/
 /*
 -------------------------------------------------------------------------
    This file is part of BayesOpt, an efficient C++ library for 
    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
 ------------------------------------------------------------------------
 */
-/*
+/* 
+   Original file obtained from:
+   Logging In C++
+   By Petru Marginean, September 05, 2007
+   http://www.drdobbs.com/cpp/logging-in-c/201804215
+
   Configure:
-FILELog::ReportingLevel() = logDEBUG3;
-FILE* log_fd = fopen( "mylogfile.txt", "w" );
-Output2FILE::Stream() = log_fd;
+     FILELog::ReportingLevel() = logDEBUG3;
+     FILE* log_fd = fopen( "mylogfile.txt", "w" );
+     Output2FILE::Stream() = log_fd;
 
   Usage:
-FILE_LOG(logWARNING) << "Ops, variable x should be " << expectedX << "; is " << realX;
+     FILE_LOG(logWARNING) << "Ops, variable x should be " << expectedX << "; is " << realX;
 */
 
 #ifndef __LOG_HPP__
 
 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
 
+#define NOMINMAX
 #include <windows.h>
 
 inline std::string NowTime()
 
 inline std::string NowTime()
 {
-    char buffer[11];
-    time_t t;
-    time(&t);
-    tm r = {0};
-    strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r));
-    struct timeval tv;
-    gettimeofday(&tv, 0);
-    char result[100] = {0};
-    std::sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); 
-    return result;
+  struct timeval tv;
+  gettimeofday(&tv, 0);
+  char buffer[11];
+  tm r = {0};
+  strftime(buffer, sizeof(buffer), "%X", localtime_r(&tv.tv_sec, &r));
+  char result[100] = {0};
+  std::sprintf(result, "%s.%06ld", buffer, (long)tv.tv_usec);
+  return result;
+
+    // char buffer[11];
+    // time_t t;
+    // time(&t);
+    // tm r = {0};
+    // strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r));
+    // struct timeval tv;
+    // gettimeofday(&tv, 0);
+    // char result[100] = {0};
+    // std::sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); 
+    // return result;
 }
 
 #endif //WIN32