Commit e07e72a8 by Konstantinos Chatzilygeroudis

Merge remote-tracking branch 'origin' into fix_docs

parents 57909657 1840bc73
 ... ... @@ -6,7 +6,7 @@ Using Limbo as an environment for scientific experiments The typical use case of Limbo for research in Bayesian Optimization is: - we design an experiment that uses some components of Limbo - we want to konw whether variant X of the experiment (e.g. with kernel XXX) is better than variant Y (e.g. with kernel YYY) - we want to know whether variant X of the experiment (e.g. with kernel XXX) is better than variant Y (e.g. with kernel YYY) - because the algorithms that we use have some stochastic components (initialization, inner optimization, ...), we usually need to replicate each experiment (typically, we use 30 replicates) in order to do some statistics (see `Matplotlib for Papers `_ for a tutorial about how to draw nice box plots with these statistics). Limbo provides basics tools to make these steps easier. They are mostly additions to ``waf`` (see our :ref:`FAQ about waf `). For users who are used to ROS, you can see these additions as our 'catkin for Bayesian optimization'. ... ...
 ... ... @@ -8,7 +8,7 @@ In this tutorial, we will explain how to create a new experiment in which a simp Let's say we want to create an experiment called "myExp". The first thing to do is to create the folder ``exp/myExp`` under the limbo root. Then add two files: * the ``main.cpp`` file * a pyhton file called ``wscript``, which will be used by ``waf`` to register the executable for building * a python file called ``wscript``, which will be used by ``waf`` to register the executable for building The file structure should look like this: :: ... ...
 ... ... @@ -99,7 +99,7 @@ struct Params { }; #ifdef USE_LIBCMAES struct opt_cmaes : public defaults::opt_cmaes { BO_PARAM(double, max_fun_evals, 500); BO_PARAM(int, max_fun_evals, 500); BO_PARAM(double, fun_tolerance, 1e-6); BO_PARAM(double, xrel_tolerance, 1e-6); }; ... ...
 ... ... @@ -115,7 +115,7 @@ namespace limbo { this->_compute_full_kernel(); } /// Do not forget to call this if you use hyper-prameters optimization!! /// Do not forget to call this if you use hyper-parameters optimization!! void optimize_hyperparams() { _hp_optimize(*this); ... ... @@ -271,12 +271,12 @@ namespace limbo { // --- cholesky --- // see: // http://xcorr.net/2008/06/11/log-determinant-of-positive-definite-matrices-in-matlab/ long double det = 2 * _matrixL.diagonal().array().log().sum(); long double logdet = 2 * _matrixL.diagonal().array().log().sum(); double a = (_obs_mean.transpose() * _alpha) .trace(); // generalization for multi dimensional observation _log_lik = -0.5 * a - 0.5 * det - 0.5 * n * std::log(2 * M_PI); _log_lik = -0.5 * a - 0.5 * logdet - 0.5 * n * std::log(2 * M_PI); return _log_lik; } ... ... @@ -556,8 +556,8 @@ namespace limbo { void _compute_incremental_kernel() { // Incremental LLT // This part of the code is inpired from the Bayesopt Library (cholesky_add_row function). // However, the mathematical fundations can be easily retrieved by detailling the equations of the // This part of the code is inspired from the Bayesopt Library (cholesky_add_row function). // However, the mathematical foundations can be easily retrieved by detailing the equations of the // extended L matrix that produces the desired kernel. size_t n = _samples.size(); ... ...
 ... ... @@ -76,7 +76,7 @@ namespace limbo { /// useful because the model might be created before knowing anything about the process SparsifiedGP() : base_gp_t() {} /// useful because the model might be created before having samples /// useful because the model might be created before having samples SparsifiedGP(int dim_in, int dim_out) : base_gp_t(dim_in, dim_out) {} ... ...
 ... ... @@ -68,7 +68,7 @@ namespace limbo { BO_PARAM(int, restarts, 1); /// @ingroup opt_defaults /// maximum number of calls to the function to be optimized BO_PARAM(double, max_fun_evals, -1); BO_PARAM(int, max_fun_evals, -1); /// @ingroup opt_defaults /// threshold based on the difference in value of a fixed number /// of trials: if bigger than 0, it enables the tolerance criteria ... ... @@ -112,8 +112,19 @@ namespace limbo { /// @ingroup opt_defaults /// upper bound (in input) for cmaes BO_PARAM(double, ubound, 1.0); /// @ingroup opt_defaults /// if stochastic, the mean of the /// last distribution is returned /// otherwise, the best ever candidate /// is returned. If handle_uncertainty is on, /// this is also enabled. BO_PARAM(bool, stochastic, false); /// @ingroup opt_defaults /// number of parent population /// -1 to automatically determine BO_PARAM(int, lambda, -1); }; } } // namespace defaults namespace opt { /// @ingroup opt ... ... @@ -127,7 +138,7 @@ namespace limbo { /// - int variant /// - int elitism /// - int restarts /// - double max_fun_evals /// - int max_fun_evals /// - double fun_tolerance /// - double xrel_tolerance /// - double fun_target ... ... @@ -136,6 +147,8 @@ namespace limbo { /// - bool verbose /// - double lb (lower bounds) /// - double ub (upper bounds) /// - bool stochastic /// - int lambda template struct Cmaes { public: ... ... @@ -167,11 +180,14 @@ namespace limbo { double sigma = 0.5; std::vector x0(init.data(), init.data() + init.size()); CMAParameters<> cmaparams(x0, sigma); CMAParameters<> cmaparams(x0, sigma, Params::opt_cmaes::lambda()); _set_common_params(cmaparams, dim); // the optimization itself CMASolutions cmasols = cmaes<>(f_cmaes, cmaparams); if (Params::opt_cmaes::stochastic() || Params::opt_cmaes::handle_uncertainty()) return cmasols.xmean(); return cmasols.get_best_seen_candidate().get_x_dvec(); } ... ... @@ -192,13 +208,14 @@ namespace limbo { double sigma = 0.5 * std::abs(Params::opt_cmaes::ubound() - Params::opt_cmaes::lbound()); std::vector x0(init.data(), init.data() + init.size()); // -1 for automatically decided lambda, 0 is for random seeding of the internal generator. CMAParameters> cmaparams(dim, &x0.front(), sigma, -1, 0, gp); CMAParameters> cmaparams(dim, &x0.front(), sigma, Params::opt_cmaes::lambda(), 0, gp); _set_common_params(cmaparams, dim); // the optimization itself CMASolutions cmasols = cmaes>(f_cmaes, cmaparams); //cmasols.print(std::cout, 1, gp); //to_f_representation if (Params::opt_cmaes::stochastic() || Params::opt_cmaes::handle_uncertainty()) return gp.pheno(cmasols.xmean()); return gp.pheno(cmasols.get_best_seen_candidate().get_x_dvec()); } ... ... @@ -259,7 +276,7 @@ namespace limbo { cmaparams.set_quiet(!Params::opt_cmaes::verbose()); } }; } } #endif } // namespace opt } // namespace limbo #endif #endif \ No newline at end of file
 ... ... @@ -99,7 +99,7 @@ struct Params { struct Eval { // number of input dimension (x.size()) BO_PARAM(size_t, dim_in, 1); // number of dimenions of the result (res.size()) // number of dimensions of the result (res.size()) BO_PARAM(size_t, dim_out, 1); // the function to be optimized ... ...
 ... ... @@ -61,6 +61,7 @@ import limbo, benchmarks import inspect from waflib import Logs from waflib.Build import BuildContext from waflib.Errors import WafError def options(opt): opt.load('compiler_cxx boost waf_unit_test') ... ... @@ -87,10 +88,23 @@ def options(opt): opt.add_option('--tests', action='store_true', help='compile tests or not', dest='tests') opt.add_option('--write_params', type='string', help='write all the default values of parameters in a file (used by the documentation system)', dest='write_params') opt.add_option('--regression_benchmarks', type='string', help='config file (json) to compile benchmark for regression', dest='regression_benchmarks') opt.add_option('--cpp14', action='store_true', default=False, help='force c++-14 compilation [--cpp14]', dest='cpp14') try: os.mkdir(blddir)# because this is not always created at that stage except: print("build dir not created (it probably already exists, this is fine)") opt.logger = Logs.make_logger(blddir + '/options.log', 'mylogger') for i in glob.glob('exp/*'): if os.path.isdir(i): opt.recurse(i) opt.start_msg('command-line options for [%s]' % i) try: opt.recurse(i) opt.end_msg(' -> OK') except WafError: opt.end_msg(' -> no options found') opt.recurse('src/benchmarks') ... ... @@ -107,6 +121,12 @@ def configure(conf): conf.load('libcmaes') native_flags = "-march=native" is_cpp14 = conf.options.cpp14 if is_cpp14: is_cpp14 = conf.check_cxx(cxxflags="-std=c++14", mandatory=False, msg='Checking for C++14') if not is_cpp14: conf.msg('C++14 is requested, but your compiler does not support it!', 'Disabling it!', color='RED') if conf.env.CXX_NAME in ["icc", "icpc"]: common_flags = "-Wall -std=c++11" opt_flags = " -O3 -xHost -g" ... ... @@ -120,6 +140,9 @@ def configure(conf): common_flags += " -fdiagnostics-color" opt_flags = " -O3 -g" if is_cpp14: common_flags = common_flags + " -std=c++14" native = conf.check_cxx(cxxflags=native_flags, mandatory=False, msg='Checking for compiler flags \"'+native_flags+'\"') if native: opt_flags = opt_flags + ' ' + native_flags ... ... @@ -226,7 +249,7 @@ def write_default_params(ctx): def build_docs(ctx): Logs.pprint('NORMAL', "generating HTML doc with versioning...") s = 'sphinx-versioning -v build -f docs/pre_script.sh --whitelist-branches "(master|release-*)" docs docs/_build/html' s = 'sphinx-versioning -v build -f docs/pre_script.sh --whitelist-branches "(fix\_docs|master|release-*)" docs docs/_build/html' retcode = subprocess.call(s, shell=True, env=None) class BuildExtensiveTestsContext(BuildContext): ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!