Skip to content

Commit

Permalink
cmaeswrapper was broken on old matlab versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tholden committed Sep 2, 2016
1 parent f1ab575 commit 368baa3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Core/CMAESWrapper.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
function [ x, f ] = CMAESWrapper( OptiFunction, x, lb, ub, varargin )

OpenPool;

try
pool = gcp;
nw = pool.NumWorkers;
catch
nw = 1;
try
nw = matlabpool( 'size' ); %#ok<DPOOL>
catch
nw = 1;
end
end

cmaesOptions = cmaes;
cmaesOptions.EvalParallel = 1;
cmaesOptions.PopSize = [ 'max( ' int2str( nw ) ', (4 + floor(3*log(N))) )' ];
Expand All @@ -20,5 +28,6 @@
[~,~,~,~,~,best] = CMAESMinimisation( @( XV ) CMAESParallelWrapper( OptiFunction, XV ), x, sigma, cmaesOptions );
x = max( lb, min( ub, best.x ) );
f = best.f;

end

0 comments on commit 368baa3

Please sign in to comment.