# BayesOpt / doxygen / contribute.dox

 Ruben Martinez-C… a5f934f 2013-06-05 Ruben Martinez-C… c20fdd2 2013-07-24 Ruben Martinez-C… a5f934f 2013-06-05  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 /*! \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 only if you need to modify 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 \section relsoft Related software \li Spearmint (Python): A library based on \cite Snoek2012. It is more oriented to cluster computing https://github.com/JasperSnoek/spearmint \li Hyperopt (Python): A library mainly based on \cite Bergstra2011. It uses different models for the surrogate model https://github.com/jaberg/hyperopt \li Perk (Fortran+Shell): A library for surrogate modelling. It was mainly used in \cite Santner03. http://www.stat.osu.edu/~comp_exp/book.html \li SUMO (Matlab): A library for surrogate modelling. Its main purpose it is not optimization but it also includes the Expected Imporvement algorithm. http://www.sumowiki.intec.ugent.be/Main_Page \li GPML (Matlab): The most popular library for Gaussian Process. BayesOpt uses some of its design principles. http://www.gaussianprocess.org/gpml/code/matlab/doc/ \li NLOPT (C-Many languages): One of the best libraries for general purpose nonlinear optimization. http://ab-initio.mit.edu/wiki/index.php/NLopt */