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