1% Sample calling syntax for testing taopounders and comparing to fminsearch 2% ProblemFinalize is called after solving the instance 3 4% Pad the history if there are remaining evaluations or truncate if too many 5if nfev < nfmax 6 fvals = [fvals(1:nfev);ones(nfmax-nfev,1)*fvals(nfev)]; 7else 8 fvals = fvals(1:nfmax); 9 fvecs = fvecs(1:nfmax,:); 10 X_hist = X_hist(1:nfmax,:); 11end 12 13% Store the history and results for taopounders 14SolverNumber = 1; 15Results{SolverNumber,np}.alg = 'TAO Pounders'; 16Results{SolverNumber,np}.problem = ['problem ' num2str(np) ' from More/Wild']; 17Results{SolverNumber,np}.H = fvals; 18Results{SolverNumber,np}.X = X_hist; 19Results{SolverNumber,np}.fvecs = fvecs; 20 21% Initialize the function handle for evaluating the norm of the residuals 22func = @(x)dfovec_wrap(m,n,x,nprob,0); 23 24% Initialize the algorithmic parameters for fminsearch 25rand('seed',0); 26options = optimset('MaxFunEvals',nfmax,'MaxIter',nfmax); 27 28% Reset the global history of the evaluations 29nfev = 0; 30fvals = zeros(nfmax,1); 31fvecs = zeros(nfmax,m); 32X_hist = zeros(nfmax,n); 33 34% Call fminsearch 35fminsearch(func,X0,options); 36 37% Pad the history if there are remaining evaluations or truncate if too many 38if nfev < nfmax 39 fvals = [fvals(1:nfev);ones(nfmax-nfev,1)*fvals(nfev)]; 40else 41 fvals = fvals(1:nfmax); 42 fvecs = fvecs(1:nfmax,:); 43 X_hist = X_hist(1:nfmax,:); 44end 45 46% Store the history and results for taopounders 47SolverNumber = 2; 48Results{SolverNumber,np}.alg = 'fminsearch'; 49Results{SolverNumber,np}.problem = ['problem ' num2str(np) ' from More/Wild']; 50Results{SolverNumber,np}.H = fvals; 51Results{SolverNumber,np}.X = X_hist; 52Results{SolverNumber,np}.fvecs = fvecs; 53 54