How does a vectorized MATLAB / Optimization toolbox algorithm decide if X (output to objective function) is going to be a single point or several points?
2 views (last 30 days)
Show older comments
How does a vectorized pattern search alghoritm decide if the X should be a single point or several points?
In the global optimization toolbox user's guide R2019b chapter:(4-111) there is the following text:
"Note Write your vectorized objective function or nonlinear constraint function to accept a matrix with an arbitrary number of points. patternsearch sometimes evaluates a single point even during a vectorized calculation."
I am interested in when/why pattern search only evaluates a single point instead of several?
I have looked in the user's manual for a more detailed explinatation but have not found one, maybe I have missed something?
-------------------------------- Example ------------------------------------
One simple example:
%% SimpleTest
ObjectiveFunction = @SimpleFunc;
options = optimoptions('patternsearch');
options = optimoptions(@patternsearch,'PlotFcn',{@psplotbestf}, ...
'Display','iter');
InitialMeshSize_Data=1;
options = optimoptions(options,'UseVectorized', true);
options = optimoptions(options,'InitialMeshSize', InitialMeshSize_Data);
options = optimoptions(options,'UseCompletePoll', true);
options = optimoptions(options,'SearchFcn', @GPSPositiveBasisNp1);
options = optimoptions(options,'Display', 'off');
lb=[];
ub=[];
x0=ones(1,10);
[x, fval] = patternsearch(ObjectiveFunction,x0,[],[],[],[],lb,ub,[],options)
SimpleFunc
function x_out = SimpleFunc(x_in)
for i=1:size(x_in,1)
X(i,:) = x_in(i,:).^3; % just takes the input value to the power of 3.
end
for ii=1:size(X,1)
x_sum(ii) = sum(X(ii,:)); % sums the rows to and returns as the Value
end
x_out=x_sum;
end
If I have a breakpoint in the start of SimpleFunc and study the incoming values from pattern search. The first 'run/iteration' gives a 2-by-10 matrix (good it tests two points), but then for all the other 'runs/iterations' it only gives me a 1-by-10 vector, which means one single point (right?).
Is there any way to make the input from pattern search always or more often give a matrix to the objective function?
best regards,
Markus
2 Comments
Gifari Zulkarnaen
on 5 Apr 2020
If 'UseVectorized' is true, the incoming value supposed to be 2N/Np1-by-10 in your example. How do you set breakpoint and get the incoming values?
Answers (0)
See Also
Categories
Find more on Direct Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!