Skip to content

Commit

Permalink
Merge branch 'development' of ssh://github.com:mfeurer/automl/HPOlib …
Browse files Browse the repository at this point in the history
…into development
  • Loading branch information
mfeurer committed Jun 29, 2015
2 parents c0ae539 + 405ccb1 commit 94d4d84
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/ROAR_smac_2_06_01-dev
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/ROAR_smac_2_08_00-master
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/ROAR_smac_2_10_00-dev
59 changes: 59 additions & 0 deletions benchmarks/matlab_branin/branin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function [value] = branin(varargin)
% Branin test function
%
% The number of variables n = 2.
% constraints:
% -5 <= x <= 10, 0 <= y <= 15
% three global optima: (-pi, 12.275), (pi, 2.275), (9.42478, 2.475),
% where branin = 0.397887"""

% constraints are not tested
tic;
% extract hyperparameters
% everything before --params is an option, everything after is a hyperparameter
[hyperparams, clioptions] = extract_hyperparams(varargin);

x = hyperparams.x;
y = hyperparams.y;

value = (y - (5.1/(4*pi^2)) * x^2 + 5*x/pi - 6)^2;
value = value + (10 * (1 - 1/(8*pi)) * cos(x) + 10);

elapsedTime = toc;
display(sprintf('Result for ParamILS: SAT, %f, 1, %f, %d, x: %f; y: %f; matlab_branin', ...
abs(elapsedTime), value, -1, x, y));
end

function [hyperparams, options] = extract_hyperparams(cli_string)
hyperparams_start = find(strcmp(cli_string, '--params'));
hyperparams = cli_string(hyperparams_start+1:end);
options = cli_string(1:hyperparams_start-1);

% build hyperparameter struct
% 1. remove single minus in front of hyperparameters
for i=1:2:numel(hyperparams)
display(hyperparams{i}(1));
assert(hyperparams{i}(1) == '-', 'Expect a minus in front of the parameter key');
hyperparams{i} = hyperparams{i}(2:end);
end
% 2. Make struct
hyperparams = struct(hyperparams{:});
% 3. Try to convert everything to numeric
param_keys = fieldnames(hyperparams);
for i = 1:numel(param_keys)
numeric_param = str2double(hyperparams.(param_keys{i}));
if ~isnan(numeric_param)
hyperparams.(param_keys{i}) = numeric_param;
end
end

% build options struct
% 2. expect double minus in front of options
for i=1:2:numel(options)
display(options{i}(1));
assert(options{i}(1) == '-' && options{i}(2) == '-', 'Expect a double minus in front of the option key');
options{i} = options{i}(3:end);
end
% 2. Make struct
options = struct(options{:});
end
14 changes: 14 additions & 0 deletions benchmarks/matlab_branin/config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[SMAC]
p = params.pcs

[TPE]
space = space.py

[SPEARMINT]
config = config.pb

[HPOLIB]
console_output_delay = 2.0
function = bash ../matlab_batcher.sh ../ branin
number_of_jobs = 200
result_on_terminate = 1000
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/hyperopt_august2013_mod
42 changes: 42 additions & 0 deletions benchmarks/matlab_branin/matlab_batcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

matlab_exec=matlab

#Remove the first arguments
i=0
for var in "$@"
do
args[$i]=$var
let i=$i+1
done

# Third argument is the directory
HERE=`pwd`
MDIR=${args[0]}
echo "CD to is" $MDIR
unset args[0]
unset args[1]
cd $MDIR

#Construct the Matlab function call
X="${2}("
for arg in ${args[*]} ; do
#If the variable is not a number, enclose in quotes
if ! [[ "$arg" =~ ^[0-9]+([.][0-9]+)?$ ]] ; then
X="${X}'"$arg"',"
else
X="${X}"$arg","
fi
done
X="${X%?}"
X="${X})"

echo The MATLAB function call is ${X}

#Call Matlab
echo "cd('`pwd`');${X}" > matlab_command.m
${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command.m

cd $HERE
#Remove the matlab function call
rm matlab_command.m
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/random_hyperopt_august2013_mod
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/smac_2_06_01-dev
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/smac_2_08_00-master
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/smac_2_10_00-dev
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/spearmint_april2013_mod
1 change: 1 addition & 0 deletions benchmarks/matlab_branin/spearmint_gitfork_mod
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

* HPOlib/Plotting/results.py: New result print script which can be used while the experiment is still running
* HPOlib/Plotting/doFanovaPlots.py;HPOlib/scripts/HPOlib-pyFanova: New plotting script that calls pyfanova and saves plots
* HPOlib/benchmarks: added a matlab examples running the branin textfunctions, contains an argumentparser

=== Other ===

Expand Down

0 comments on commit 94d4d84

Please sign in to comment.