Skip to content
Snippets Groups Projects
Commit cfce048a authored by Stéphane Adjemian's avatar Stéphane Adjemian Committed by GitHub
Browse files

Merge pull request #1471 from JohannesPfeifer/simpsa

simpsa: Only store output strcuture if requested
parents ca1a9e4a 89326090
No related branches found
No related tags found
No related merge requests found
......@@ -142,8 +142,9 @@ DEFAULT_OPTIONS = simpsaset('TEMP_START',[],... % starting temperature (if none
OPTIONS = simpsaset(DEFAULT_OPTIONS,OPTIONS);
% store options in OUTPUT
if nargout>3
OUTPUT.OPTIONS = OPTIONS;
end
% initialize simplex
% ------------------
......@@ -175,13 +176,13 @@ end
% initialize OUTPUT structure
% ---------------------------
if nargout>3
OUTPUT.TEMPERATURE = zeros(OPTIONS.MAX_ITER_TOTAL,1);
OUTPUT.SIMPLEX = zeros(NDIM+1,NDIM,OPTIONS.MAX_ITER_TOTAL);
OUTPUT.SIMPLEX_BEST = zeros(OPTIONS.MAX_ITER_TOTAL,NDIM);
OUTPUT.COSTS = zeros(OPTIONS.MAX_ITER_TOTAL,NDIM+1);
OUTPUT.COST_BEST = zeros(OPTIONS.MAX_ITER_TOTAL,1);
end
% initialize iteration data
% -------------------------
......@@ -304,6 +305,7 @@ while 1
Y = help(:,2);
P = help(:,3:end);
if nargout>3
% store temperature at current iteration
OUTPUT.TEMPERATURE(nITERATIONS) = TEMP;
......@@ -314,6 +316,7 @@ while 1
% store cost function value of best vertex in current iteration
OUTPUT.COSTS(nITERATIONS,:) = Y;
OUTPUT.COST_BEST(nITERATIONS) = YBEST;
end
if strcmp(OPTIONS.DISPLAY,'iter')
disp(sprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP));
......@@ -452,6 +455,7 @@ end
X = transpose(PBEST);
FVAL = YBEST;
if nargout>3
% store number of function evaluations
OUTPUT.nFUN_EVALS = nFUN_EVALS;
......@@ -467,6 +471,7 @@ OUTPUT.COST_BEST(nITERATIONS+1:end) = [];
% store the amount of time needed in OUTPUT data structure
OUTPUT.TIME = toc;
end
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment