Bayesian-Optimization / 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;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.