global numf numg numH numFact global resid % NOW DO LBFGS STUFF nparams = struct('maxit',1000,'toler',1.0e-4,'delbar',100,'eta',0.1,'initdel',1); nparams.m = 3; fprintf('\n\nLBFGS memory parameter = %d\n',nparams.m); probname = 'brownal'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'watson'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'geodesic'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'cragglvy'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'woods'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); nparams.m = 5; fprintf('\n\nLBFGS memory parameter = %d\n',nparams.m); probname = 'brownal'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'watson'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'geodesic'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'cragglvy'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'woods'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); nparams.m = 17; fprintf('\n\nLBFGS memory parameter = %d\n',nparams.m); probname = 'brownal'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'watson'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'geodesic'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'cragglvy'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'woods'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); nparams.m = 29; fprintf('\n\nLBFGS memory parameter = %d\n',nparams.m); probname = 'brownal'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'watson'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'geodesic'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'cragglvy'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'woods'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = LBFGS(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n\n',numH); probname = 'brownal'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = DogLeg(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n',numH); fprintf('No. Factorizations %d\n\n',numFact); probname = 'watson'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = DogLeg(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n',numH); fprintf('No. Factorizations %d\n\n',numFact); probname = 'geodesic'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = DogLeg(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n',numH); fprintf('No. Factorizations %d\n\n',numFact); probname = 'cragglvy'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = DogLeg(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n',numH); fprintf('No. Factorizations %d\n\n',numFact); probname = 'woods'; [x,bl,bu,v,cl,cu] = spamfunc(probname); x = struct('p',x); fprintf('Problem: %s, size (%d)\n',probname,length(x.p)); tic, [inform,xnew] = DogLeg(@objampl,x,nparams); toc, % tic, [inform,xnew] = TNewton(@objampl,x,nparams); toc, if inform.status == 0 fprintf('CONVERGENCE FAILURE: %d steps were taken without\n', inform.iter); fprintf('gradient size decreasing below %8.4g.\n\n', nparams.toler); else fprintf('Success: %d steps taken\n\n', inform.iter); end fprintf('Ending value: %8.4g\n',xnew.f); fprintf('No. function evaluations: %d\n',numf); fprintf('No. gradient evaluations %d\n',numg); fprintf('Norm of ending gradient: %8.4g\n', norm(xnew.g)); fprintf('No. Hessian evaluations %d\n',numH); fprintf('No. Factorizations %d\n\n',numFact);