Q=[3 -1;-1 5] Q = 3 -1 -1 5 eig(Q) ans = 2.5858 5.4142 [X1,X2]=meshgrid(-3:0.1:3,-2:0.1:2); S=c(1)*X1+c(2)*X2+1/2*(Q(1,1)*X1.*X1+2*X1.*X2*Q(1,2)+Q(2,2)*X2.*X2); mesh(X1,X2,S) xo=-inv(Q)*c xo = -0.5000 -0.5000 So=1/2*c'*xo So = -0.7500 Q=[3 0;0 0] Q = 3 0 0 0 Q=[3 -1;-1 0] Q = 3 -1 -1 0 eig(Q) ans = 3.3028 -0.3028 Q=[3 0;0 0] Q = 3 0 0 0 S=c(1)*X1+c(2)*X2+1/2*(Q(1,1)*X1.*X1+2*X1.*X2*Q(1,2)+Q(2,2)*X2.*X2); mesh(X1,X2,S) [V,D]=eig(Q) V = 1 0 0 1 D = 3 0 0 0 Q=[3 -1;-1 -5] Q = 3 -1 -1 -5 eig(Q) ans = 3.1231 -5.1231 S=c(1)*X1+c(2)*X2+1/2*(Q(1,1)*X1.*X1+2*X1.*X2*Q(1,2)+Q(2,2)*X2.*X2); mesh(X1,X2,S) xo=-inv(Q)*c xo = -0.1875 0.4375 Q=[3 -1;-1 3] Q = 3 -1 -1 3 eig(Q) ans = 4 2 Q=[3 0;0 3] Q = 3 0 0 3 eig(Q) ans = 3 3 Q=[3 3;3 3] Q = 3 3 3 3 eig(Q) ans = 0 6 S=c(1)*X1+c(2)*X2+1/2*(Q(1,1)*X1.*X1+2*X1.*X2*Q(1,2)+Q(2,2)*X2.*X2); mesh(X1,X2,S) pwd ans = V:\cursos\pos\otimiza\aulas what M-files in the current directory V:\cursos\pos\otimiza\aulas CATALIS ex_karma gtest12 newtont test12 EXTRATOR ex_qp1 gtest13 nlconst test13 LUCRO ex_qp2 gtest2 nlp_internal test14 MINQUA ex_qp3 gtest9 powell test15 MODELO ex_swarm hkjeeves qpsub test16 OPT_RES fmincon1 htest1 refino test17 PLANOS fminunc1 htest2 restr test18 READ2 fminusub interior restr1 test19 SEMIDEF fun karmarkar restr14 test2 aurea gmilp1 lmarqua restr15 test20 bandem1 gminlp1 lp_nlp restr16 test3 bfgs gminlp2 milp1 restr17 test4 bracket gminlp3 minlp restr20 test5 buscarnd gminlp4 minlp1 rosembr test6 cgrad gminlp5 minlp2 set1 test7 checkbounds gminlp6 minlp3 setoptim test8 coggins gmodelagem minlp4 sqp test9 compdir gmurray minlp5 steepdes univar complex grad minlp6 swarm varmetr dfp grg minlpn test1 writearq dual gtest1 modelagem test10 xplot ex2_karm gtest10 newton test11 edit aurea disp(sprintf('%d',feature('SessionTool'))) 0 ; dbstatus dbstack dbstack ; disp(which('aurea')); V:\cursos\pos\otimiza\aulas\aurea.m mdbstatus 'v:\cursos\pos\otimiza\aulas\aurea.m' ; help aurea Performs line search procedure for unconstrained optimization using golden section. [stepsize,xo,Ot,nS]=aurea(S,x0,d,ip,problem,tol,mxit,stp) S: objective function x0: initial point d: search direction vector ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip problem: (-1): minimum (default), (1): maximum tol: tolerance (default = 1e-4) mxit: maximum number of iterations (default = 50*(1+4*~(ip>0))) stp: initial stepsize (default = 0.01*sqrt(d'*d)) stepsize: optimal stepsize xo: optimal point in the search direction Ot: optimal value of S in the search direction nS: number of objective function evaluations type teste1 ??? Error using ==> type teste1.m: File not found. type test1 function S=test(x) % Rosenbrock, 1960 % x0 = [-1.2, 1]' % xo = [1, 1]' % S(xo) = 0 % x0=[-0.8 0], d=[8 5] (busca Coggins) S=100*(x(2)-x(1).^2).^2+(1-x(1)).^2; S=100*(X2-X1.^2).^2+(1-X1).^2; mesh(X1,X2,S) [X1,X2]=meshgrid(-1.5:0.1:1.5,-2:0.1:2); S=100*(X2-X1.^2).^2+(1-X1).^2; mesh(X1,X2,S) [X1,X2]=meshgrid(-1.5:0.1:1.5,-1.5:0.1:3); mesh(X1,X2,S) ??? Error using ==> surface Matrix dimensions must agree. Error in ==> C:\Apps\Matlab\toolbox\matlab\graph3d\mesh.m On line 93 ==> hh = surface(x,y,z,'FaceColor',fc,'EdgeColor','flat', 'FaceLighting', 'none', 'EdgeLighting', 'flat'); S=100*(X2-X1.^2).^2+(1-X1).^2; mesh(X1,X2,S) d=[1 0] d = 1 0 x0=[-1.2 1] x0 = -1.2000 1.0000 [stepsize,xo,Ot,nS]=aurea('test1',x0,d,1) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... stepsize = 0.2050 xo = -0.9950 1.0000 Ot = 3.9900 nS = 25 [stepsize,xo,Ot,nS]=aurea('test1',x0,[3 0],1) Pause: hit any key to continue... Error in ==> V:\cursos\pos\otimiza\aulas\aurea.m On line 83 ==> disp('Pause: hit any key to continue...'); pause; [stepsize,xo,Ot,nS]=aurea('test1',x0,[8 0],1) Pause: hit any key to continue... Error in ==> V:\cursos\pos\otimiza\aulas\aurea.m On line 83 ==> disp('Pause: hit any key to continue...'); pause; help aurea Performs line search procedure for unconstrained optimization using golden section. [stepsize,xo,Ot,nS]=aurea(S,x0,d,ip,problem,tol,mxit,stp) S: objective function x0: initial point d: search direction vector ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip problem: (-1): minimum (default), (1): maximum tol: tolerance (default = 1e-4) mxit: maximum number of iterations (default = 50*(1+4*~(ip>0))) stp: initial stepsize (default = 0.01*sqrt(d'*d)) stepsize: optimal stepsize xo: optimal point in the search direction Ot: optimal value of S in the search direction nS: number of objective function evaluations [stepsize,xo,Ot,nS]=aurea(S,x0,d,1,[],[],[],3) ??? Error using ==> feval Argument must contain a string. Error in ==> V:\cursos\pos\otimiza\aulas\bracket.m On line 32 ==> y0=feval(S,x0)*problem; Error in ==> V:\cursos\pos\otimiza\aulas\aurea.m On line 50 ==> [x1,x2,nS]=bracket(S,x0,d,problem,stepsize); [stepsize,xo,Ot,nS]=aurea('test1',x0,d,1,[],[],[],3) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... stepsize = 0.2051 xo = -0.9949 1.0000 Ot = 3.9900 nS = 28 [stepsize,xo,Ot,nS]=aurea('test1',[-1 1],d,1,[],[],[],3) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... stepsize = 2.0000 xo = 1.0000 1.0000 Ot = 6.2356e-008 nS = 28 help coggins Performs line search procedure for unconstrained optimization using quadratic interpolation. [stepsize,xo,Ot,nS]=coggins(S,x0,d,ip,problem,tol,mxit) S: objective function x0: initial point d: search direction vector ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip problem: (-1): minimum (default), (1): maximum tol: tolerance (default = 1e-4) mxit: maximum number of iterations (default = 50*(1+4*~(ip>0))) stp: initial stepsize (default = 0.01*sqrt(d'*d)) stepsize: optimal stepsize xo: optimal point in the search direction Ot: optimal value of S in the search direction nS: number of objective function evaluations type test1 function S=test(x) % Rosenbrock, 1960 % x0 = [-1.2, 1]' % xo = [1, 1]' % S(xo) = 0 % x0=[-0.8 0], d=[8 5] (busca Coggins) S=100*(x(2)-x(1).^2).^2+(1-x(1)).^2; [stepsize,xo,Ot,nS]=coggins('test1',[-0.8 0],[8 5],1) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... stepsize = 0.0432 xo = -0.4543 0.2160 Ot = 2.1243 nS = 20 [stepsize,xo,Ot,nS]=coggins('test1',[-0.6 0],[8 5],1) Pause: hit any key to continue... Error in ==> V:\cursos\pos\otimiza\aulas\coggins.m On line 77 ==> disp('Pause: hit any key to continue...'); pause; [stepsize,xo,Ot,nS]=coggins('test1',[-0.7 0],[8 5],1) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Error in ==> V:\cursos\pos\otimiza\aulas\coggins.m On line 101 ==> disp('Pause: hit any key to continue...'); pause; help univar Unconstrained optimization using univariate search (Coggins and Gold Section). [xo,Ot,nS]=univar(S,x0,ip,method,Lb,Ub,problem,tol,mxit) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip method: (0) Coggins (default), (1): Golden Section Lb, Ub: lower and upper bound vectors to plot (default = x0*(1+/-2)) problem: (-1): minimum (default), (1): maximum tol: tolerance (default = 1e-4) mxit: maximum number of stages (default = 50*(1+4*~(ip>0))) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations type test1 function S=test(x) % Rosenbrock, 1960 % x0 = [-1.2, 1]' % xo = [1, 1]' % S(xo) = 0 % x0=[-0.8 0], d=[8 5] (busca Coggins) S=100*(x(2)-x(1).^2).^2+(1-x(1)).^2; [xo,Ot,nS]=univar('test1',x0,1,0) Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Warning Univar: reached maximum number of stages! xo = -0.6719 0.4515 Ot = 2.7954 nS = 934 help univar Unconstrained optimization using univariate search (Coggins and Gold Section). [xo,Ot,nS]=univar(S,x0,ip,method,Lb,Ub,problem,tol,mxit) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip method: (0) Coggins (default), (1): Golden Section Lb, Ub: lower and upper bound vectors to plot (default = x0*(1+/-2)) problem: (-1): minimum (default), (1): maximum tol: tolerance (default = 1e-4) mxit: maximum number of stages (default = 50*(1+4*~(ip>0))) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations [xo,Ot,nS]=univar('test1',x0,-1,0,[],[],[],[],5000) xo = 0.9746 0.9499 Ot = 6.4380e-004 nS = 16732 quit