Recovering list of polling points with patternsearch

Hi,
I'm currently using patternsearch to minimize a highly non-linear function with 5 arguments. I'd like to know, if there's a way to recover a list of the polling points that the patternsearch algorithm has evaluated with the respective value of my objective function. I'm running patternseach from an m-file not using optimtool -- I don't know if that's relevant for my question.
Any help is gratefully appreciated!

Answers (1)

The solution is a little dangerous :)
Go to directory matlabroot/toolbox/globaloptim/globaloptim/private/:
cd(matlabroot)
cd toolbox/globaloptim/globaloptim/private/
and edit funevaluate.m ( make sure that you have done the copy of this file! ):
open funevaluate.m
Add at the beginning of the file the following lines:
global X_global
X_global(:,end+1) = X;
Now you can try run patternsearch in this way:
global X_global
xmin = patternsearch(@ps_example,[pi pi]);
And draw the polling points:
[x y] = meshgrid(-15:.1:15);
z = NaN(size(x));
for k1=1:size(x,1)
for k2=1:size(x,2)
z(k1,k2) = ps_example([x(k1,k2) y(k1,k2)]);
end
end
contour(x,y,z,40)
hold on
plot(pi,pi,'ko')
plot(X_global(1,:),X_global(2,:),'.r')
plot(xmin(1),xmin(2),'+g')
hold off
Remember to restore the original funevaluate.m file!

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 13 Jun 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!