Skip to content

Commit b6f3dfa

Browse files
minor edits with bobyqa+coordinatesearch
1 parent 9f28f92 commit b6f3dfa

File tree

6 files changed

+22
-42
lines changed

6 files changed

+22
-42
lines changed

bobyqa/bobyqaFunHandleWrap.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function [ y ] = bobyqaFunHandleWrap(x, calfun)
2+
% This is a wrapper to compute the objective function value.
3+
% Called from within the mexbobyqa routine.
4+
% funHandleWrap currently uses a global variable in bobyqa.m,
5+
% the argument calfun is not used.
6+
%
7+
% Input:
8+
% x: parameter vector
9+
% calfun: objective function handle or string representation
10+
%
11+
% Output:
12+
% y: objective function value
13+
14+
fun = bobyqa();
15+
y = fun(x);
16+
17+
end

bobyqa/funHandleWrap.m

Lines changed: 0 additions & 15 deletions
This file was deleted.

bobyqa/mexbobyqa.F

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ SUBROUTINE CALFUN (N,X,F)
138138

139139
NLHS1 = 1
140140

141-
CALL MEXCALLMATLAB(NLHS1,PLHS1,NRHS1,PRHS1,'funHandleWrap')
141+
CALL MEXCALLMATLAB(NLHS1,PLHS1,NRHS1,PRHS1,'bobyqaFunHandleWrap')
142142

143143
pF = MXGETPR(PLHS1(1))
144144
CALL MXCOPYPTRTOREAL8(pF,F,1)

getMultiStarts.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@
298298
parameters = performOptimizationLsqnonlin(parameters, negLogPost, iMS, par0, J_0, options);
299299

300300
case 'cs'
301-
% Optimization using coordinate search as local optimizer
302-
parameters = performOptimizationCs(parameters, negLogPost, iMS, par0, J_0, options);
301+
% Optimization using randomized coordinate search as local optimizer
302+
parameters = performOptimizationCoordinateSearch(parameters, negLogPost, iMS, par0, J_0, options);
303303

304304
case 'dhc'
305305
% Optimization using dynamic hill climbing as local optimizer

private/coordinateSearch.m

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function [ x, fval, exitflag, output ] = coordinateSearch( fun, x0, lb, ub, options )
2-
% performs a simple coordinate search with random update of search
2+
% Performs a simple coordinate search with random update of search
33
% directions after a failure in improving the current value.
44
%
55
% Input:
@@ -93,7 +93,6 @@
9393
fcur = fun(ycur,jIter);
9494
funcCount = funcCount + 1;
9595
% simulate finite differences
96-
% surroundingValues = zeros(2*dim,1);
9796
if (fcur < fbst)
9897
ybst = ycur;
9998
fbst = fcur;
@@ -106,8 +105,6 @@
106105
break;
107106
end
108107

109-
% surroundingValues(jSpinner,1) = fcur;
110-
111108
% update coordinate index
112109
if jSpinner == 2*dim
113110
jSpinner = 1;
@@ -116,25 +113,6 @@
116113
end
117114
end
118115

119-
% apparently bad effects
120-
% if (~iterSuccessful)
121-
% finiteDifferences = zeros(dim,1);
122-
% for j=1:dim
123-
% finiteDifferences(j) = (surroundingValues(j)-surroundingValues(dim+j))/(2*delta);
124-
% end
125-
% U = step(:,1:dim);
126-
% finiteDifferences = transpose(transpose(finiteDifferences)/U);
127-
% ycur = ybst - delta*finiteDifferences/norm(finiteDifferences);
128-
% fcur = fun(ycur);
129-
% funcCount = funcCount + 1;
130-
% if (fcur < fbst)
131-
% ybst = ycur;
132-
% fbst = fcur;
133-
%
134-
% %iterSuccessful = true;
135-
% end
136-
% end
137-
138116
if (~iterSuccessful)
139117
delta = contractFactor * delta;
140118
end

private/performOptimizationCs.m renamed to private/performOptimizationCoordinateSearch.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function parameters = performOptimizationCs(parameters, negLogPost, iMS, par0, J_0, options)
1+
function parameters = performOptimizationCoordinateSearch(parameters, negLogPost, iMS, par0, J_0, options)
22

33

44
% Definition of index set of optimized parameters

0 commit comments

Comments
 (0)