2 % -------------------------------------------------------------------------
3 % This file is part of BayesOpt, an efficient C++ library for
4 % Bayesian optimization.
6 % Copyright (C) 2011-2015 Ruben Martinez-Cantin <rmcantin@unizar.es>
8 % BayesOpt is free software: you can redistribute it and/or modify it
9 % under the terms of the GNU Affero General Public License as published by
10 % the Free Software Foundation, either version 3 of the License, or
11 % (at your option) any later version.
13 % BayesOpt is distributed in the hope that it will be useful, but
14 % WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 % GNU Affero General Public License
for more details.
18 % You should have received a copy of the GNU Affero General Public License
19 % along with BayesOpt. If not, see <http:
20 % ------------------------------------------------------------------------
23 addpath('testfunctions')
26 params.n_iterations = 200;
27 params.n_init_samples = 10;
28 params.crit_name =
'cEI';
29 params.surr_name =
'sStudentTProcessNIG';
31 params.kernel_name =
'kMaternARD5';
32 params.kernel_hp_mean = [1 1];
33 params.kernel_hp_std = [10 10];
34 params.verbose_level = 5;
35 params.log_filename =
'matbopt.log';
37 fun =
'braninhighdim'; % the
function has an effective 2D
38 n = 2; % number of low dims (effective)
39 nh = 1000; % number of actual dims
41 global MATRIX_A % random proyection matrix
42 global TRUE_I % indexes of relevant components
46 % Bounds of proyected (low-dim) space
47 lb = ones(n,1)*-sqrt(n);
48 ub = ones(n,1)*sqrt(n);
50 % rembo iterations results
51 nrembo = 10; % number of rembo iterations
52 values = zeros(nrembo,1);
53 points = zeros(nrembo,n);
56 disp(
'Running optimization');
57 MATRIX_A = randn(nh,n);
60 [result, val, error] = bayesoptcont(fun,n,params,lb,ub);
63 % We project the result back to the real low-dim space
64 hd_res = MATRIX_A*result';
65 points(i,:) = hd_res(TRUE_I)
'; 68 fprintf('Opt point: %f, %f ||
', hd_res(TRUE_I)); 69 fprintf('Opt value: %f || Error: %d\n
',val, error); 72 [foo,id] = min(values); 73 fprintf('Final point: %f, %f ||
', points(id,:)); 74 fprintf('Final value: %f\n
',values(id));