help complex Unconstrained optimization using Extended Flexible Polyhedron. [xo,So,nS] = complex(S,x0,ip,Lb,Ub,problem,tol,mxit,edge,r,P1,...,P10) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) edge: initial size of the edges (default = max(0.01*norm(x0),0.1)) r: extra number of vertices (default = 0) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations P1,...,P10: variable arguments [xo,So,nS] = complex('test10',[1 1],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... 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... xo = 1.0e-004 * 0.0559 -0.2083 So = 7.9209e-010 nS = 86 help complex Unconstrained optimization using Extended Flexible Polyhedron. [xo,So,nS] = complex(S,x0,ip,Lb,Ub,problem,tol,mxit,edge,r,P1,...,P10) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) edge: initial size of the edges (default = max(0.01*norm(x0),0.1)) r: extra number of vertices (default = 0) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations P1,...,P10: variable arguments [xo,So,nS] = complex('test10',[1 1],1,[],[],[],[],[]) Pause: hit any key to continue... Error in ==> v:\cursos\pos\otimiza\aulas\complex.m On line 109 ==> disp('Pause: hit any key to continue...'); pause; help complex Unconstrained optimization using Extended Flexible Polyhedron. [xo,So,nS] = complex(S,x0,ip,Lb,Ub,problem,tol,mxit,edge,r,P1,...,P10) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) edge: initial size of the edges (default = max(0.01*norm(x0),0.1)) r: extra number of vertices (default = 0) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations P1,...,P10: variable arguments [xo,So,nS] = complex('test10',[1 1],1,[],[],[],[],[],0.5) 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... xo = 0 0 So = 0 nS = 76 [xo,So,nS] = complex('test10',[1 1],0,[],[],[],[],[],0.5) xo = 0 0 So = 0 nS = 76 tic [xo,So,nS] = complex('test10',[1 1],0,[],[],[],[],[],0.5) xo = 0 0 So = 0 nS = 76 toc elapsed_time = 3.1740 [xo,So,nS] = complex('test1',[-1.2 1],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... 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 Complex: reached maximum number of iteration xo = 0.3556 0.0996 So = 0.4872 nS = 90 help complex Unconstrained optimization using Extended Flexible Polyhedron. [xo,So,nS] = complex(S,x0,ip,Lb,Ub,problem,tol,mxit,edge,r,P1,...,P10) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) edge: initial size of the edges (default = max(0.01*norm(x0),0.1)) r: extra number of vertices (default = 0) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations P1,...,P10: variable arguments [xo,So,nS] = complex('test1',[-1.2 1],-1,[],[],[],[],1000) xo = 1.0000 1.0001 So = 5.5416e-009 nS = 196 help rosembr Unconstrained optimization using Rosembrock. [xo,Ot,nS]=rosembr(S,x0,ip,Lb,Ub,problem,tol,mxit,stp,amp,red) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) stp: stepsize vector for the independent variables (default = max(0.01*abs(x0+~x0),0.1)) amp: stepsize enlargement factor (1,oo) (default = 3) red: stepsize reduction factor (0,1) (default = 0.5) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations [xo,So,nS] = rosembr('test1',[-1.2 1],-1,[],[],[],[],1000) xo = 1.0000 1.0000 So = 3.5519e-010 nS = 345 help powell Unconstrained optimization using Powell. [xo,Ot,nS]=powell(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,So,nS] = powell('test1',[-1.2 1],-1,[],[],[],[],[],1000) xo = 1.0000 1.0000 So = 1.7272e-011 nS = 503 help hkjeeves Unconstrained optimization using Hooke & Jeeves. [xo,Ot,nS]=hkjeeves(S,x0,ip,Lb,Ub,problem,tol,mxit,stp,amp,red) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip 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))) stp: stepsize vector for the independent variables (default = max(0.01*abs(x0+~x0),0.1)) amp: stepsize enlargement factor (1,oo) (default = 1.5) red: stepsize reduction factor (0,1) (default = 0.5) xo: optimal point Ot: optimal value of S nS: number of objective function evaluations [xo,So,nS] = hkjeeves('test1',[-1.2 1],-1,[],[],[],[],1000) xo = 0.9787 0.9578 So = 4.5467e-004 nS = 2665 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,So,nS] = univar('test1',[-1.2 1],-1,0,[],[],[],[],1000) xo = 0.9746 0.9499 So = 6.4380e-004 nS = 16732 psi=rand(1000,1); x=0+4*(1*(2*psi-1)).^1/1; R=4;B=1;A=2;delta=1; x0=0;R=4;B=1;A=2;delta=1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) psi=rand(1000,1); x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) delta=3; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) delta=5; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) A=1 A = 1 delta=1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) delta=3; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) A=-1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) delta=1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) x0 x0 = 0 psi=rand(1000,1); x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) B=1; x=x0+R*((B*(A*psi-1)).^delta)/delta; A=1 A = 1 B=1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) B=-1; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) A=1.5 A = 1.5000 delta=3; x=x0+R*((B*(A*psi-1)).^delta)/delta; hist(x) help buscarnd Unconstrained global optimization using adaptive random search. [xo,Ot,nS]=buscarnd(S,x0,ip,nOt,samples,Lb,Ub,problem,tol,mxit,R,red,mem) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip nOt: maximum number of optimal points (default = 1) samples: number of samples per stage (default = 3*size(x0(:),1)) 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))) R: axis vector of the hyperellipse centered in x0 (default = max(0.1*abs(x0+~x0),1)) red: factor to reduce the size of the axis vector (0,1) (default = 0.2) mem: number of stored points during the exploration phase [0, min(18,samples-1)] xo: matrix of optimal points (column vectors) Ot: vector of optimal values of S nS: number of objective function evaluations edit buscarnd disp(sprintf('%d',feature('SessionTool'))) 0 ; dbstatus dbstack dbstack ; disp(which('buscarnd')); v:\cursos\pos\otimiza\aulas\buscarnd.m mdbstatus 'v:\cursos\pos\otimiza\aulas\buscarnd.m' eval( 'if exist(''values'',''var''), mauifunc(values), end', ''); eval( 'if exist(''of'',''var''), mauifunc(of), end', ''); eval( 'if exist(''vectors'',''var''), mauifunc(vectors), end', ''); eval( 'if exist(''exploration'',''var''), mauifunc(exploration), end', ''); eval( 'if exist(''vector'',''var''), mauifunc(vector), end', ''); eval( 'if exist(''max'',''var''), mauifunc(max), end', ''); eval( 'if exist(''default'',''var''), mauifunc(default), end', ''); eval( 'if exist(''vector'',''var''), mauifunc(vector), end', ''); eval( 'if exist(''centered'',''var''), mauifunc(centered), end', ''); eval( 'if exist(''default'',''var''), mauifunc(default), end', ''); eval( 'if exist(''point'',''var''), mauifunc(point), end', ''); eval( 'if exist(''metric'',''var''), mauifunc(metric), end', ''); eval( 'if exist(''asym2'',''var''), mauifunc(asym2), end', ''); eval( 'if exist(''metric'',''var''), mauifunc(metric), end', ''); eval( 'if exist(''constant'',''var''), mauifunc(constant), end', ''); eval( 'if exist(''distribution'',''var''), mauifunc(distribution), end', ''); ; [xo,Ot,nS]=buscarnd('test10',[1 1],1,2,[],[],[],[],[],500,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... 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... 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 Buscarnd: reached maximum number of stages! xo = 1.0e-003 * 0.2476 0.7898 Ot = 4.7792e-007 nS = 3001 [xo,Ot,nS]=buscarnd('test10',[1 1],1,1,[],[],[],[],[],500,1) Pause: hit any key to continue... Error in ==> v:\cursos\pos\otimiza\aulas\buscarnd.m On line 133 ==> disp('Pause: hit any key to continue...'); pause; [xo,Ot,nS]=buscarnd('test10',[1 1],1,1,[],[],[],[],[],500,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... Pause: hit any key to continue... xo = 1.0e-003 * 0.0637 0.4502 Ot = 1.6154e-007 nS = 199 [xo,Ot,nS]=buscarnd('test10',[1 1],1,1,[],[],[],[],[],500,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... Pause: hit any key to continue... Pause: hit any key to continue... xo = 1.0e-004 * -0.9756 -0.9416 Ot = 2.8563e-008 nS = 223 [xo,Ot,nS]=buscarnd('test10',[1 1],1,1,[],[],[],[],[],500,1,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... 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... xo = 0.0005 0.0044 Ot = 1.5964e-005 nS = 235 [xo,Ot,nS]=buscarnd('test1',[-1.2 1],1,1,[],[],[],[],[],500,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... Pause: hit any key to continue... xo = 0.6651 0.4422 Ot = 0.1122 nS = 277 [xo,Ot,nS]=buscarnd('test1',[-1.2 1],1,1,20,[],[],[],[],500,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... xo = 0.9798 0.9603 Ot = 4.1559e-004 nS = 781 [xo,Ot,nS]=buscarnd('test1',[-1.2 1],1,1,20,[],[],[],[],500,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... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... xo = 0.9419 0.8868 Ot = 0.0034 nS = 941 type test8 function S=test(x) % Cragg & Levy, 1969 % x0 = [1, 2, 2, 2]' % xo = [0, 1, 1, 1+/-n*PI]' % S(xo) = 0 S=(exp(x(1))-x(2)).^4+100*(x(2)-x(3)).^6+(tan(x(3)-x(4))).^4+x(1).^8+(x(4)-1).^2; type test9 function S=test(x) % Himmelblau, 1972 % x0 = [1, 1]' % xo = [3, 2]', xo = [3.58443, -1.84813]', xo = [-3.7793, -3.2832]' e xo = [-2.8051, 3.1313]' % S(xo) = 0 % local maximum: xo = [-0.2708, -0.9230]', S(xo) = 181.6 S=(x(1).^2+x(2)-11).^2+(x(1)+x(2).^2-7).^2; help buscarnd Unconstrained global optimization using adaptive random search. [xo,Ot,nS]=buscarnd(S,x0,ip,nOt,samples,Lb,Ub,problem,tol,mxit,R,red,mem) S: objective function x0: initial point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip nOt: maximum number of optimal points (default = 1) samples: number of samples per stage (default = 3*size(x0(:),1)) 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))) R: axis vector of the hyperellipse centered in x0 (default = max(0.1*abs(x0+~x0),1)) red: factor to reduce the size of the axis vector (0,1) (default = 0.2) mem: number of stored points during the exploration phase [0, min(18,samples-1)] xo: matrix of optimal points (column vectors) Ot: vector of optimal values of S nS: number of objective function evaluations [xo,Ot,nS]=buscarnd('test9',[1 1],1,4,20,[-5 -5],[5 5],[],[],500,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... 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... Error in ==> v:\cursos\pos\otimiza\aulas\buscarnd.m On line 253 ==> disp('Pause: hit any key to continue...'); pause; [xo,Ot,nS]=buscarnd('test9',[1 1],1,4,20,[-5 -5],[5 5],[],[],500,5) 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... xo = 3.5846 -3.7791 -2.8052 2.9996 -1.8480 -3.2832 3.1310 2.0008 Ot = 1.0e-004 * 0.0169 0.0213 0.0336 0.1050 nS = 2621 type ex_swarm function S=func(x) v1=20*x(1); v2=20*x(2); S=-sin(v1/pi).^2 .* sin(v2/pi).^2 .* (abs(v1)+abs(v2)+0.1*(v1+v2))+(v1.*v1+v2.*v2)/30; % % [xo,Ot,nS]=swarm('ex_swarm',[0 0],0,[1 1],[-1 -1],[1 1],[],100,20) % [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],1,1,20,[-2 -2],[2 2],[],[],500,1) Pause: hit any key to continue... Error in ==> v:\cursos\pos\otimiza\aulas\buscarnd.m On line 133 ==> disp('Pause: hit any key to continue...'); pause; [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],1,1,20,[-1 -1],[1 1],[],[],500,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... Pause: hit any key to continue... Pause: hit any key to continue... Pause: hit any key to continue... xo = -0.7395 0.7411 Ot = -14.9991 nS = 961 [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],1,1,20,[-1 -1],[1 1],[],[],500,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... xo = 0.7409 1.2307 Ot = -15.8445 nS = 641 [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],1,1,20,[-1 -1],[1 1],[],[],500,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... Pause: hit any key to continue... xo = 1.2307 0.7408 Ot = -15.8445 nS = 761 [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],-1,4,20,[-1 -1],[1 1],[],[],500,1) xo = 0.7413 0.7408 0.7409 0.7415 0.7412 1.2306 -0.7396 -0.2533 Ot = -17.9601 -15.8445 -14.9990 -12.6482 nS = 3321 type naturais [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],0,1,20,[-1 -1],[1 1],[],[],[],[2 2]) [xo,Ot,nS]=swarm('ex_swarm',[0 0],0,[1 1],[-1 -1],[1 1],[],100,20) % Para achar os dois melhores otimos [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],0,2,20,[-1 -1],[1 1],[],[],[],[2 2]) % Se colocar o terceiro argumento como -1 nos dois algoritmos, entao faz o grafico. tic for i=1:100, [xo,Ot(i),nS]=buscarnd('ex_swarm',[0 0],0,1,20,[-1 -1],[1 1],[],[],[],[2 2]); end tb=toc nb=find(Ot < -17); size(nb,2) figure(1); hist(Ot); legend('buscarnd'); tic for i=1:100, [xo,Ots(i),nS]=swarm('ex_swarm',[0 0],0,[1 1],[-1 -1],[1 1],[],100,20); end ts=toc ns=find(Ots < -17); size(ns,2) figure(2); hist(Ots); legend('swarm'); edit naturais disp(sprintf('%d',feature('SessionTool'))) 0 ; dbstatus dbstack dbstack ; disp(which('naturais')); v:\cursos\pos\otimiza\aulas\naturais.m mdbstatus 'v:\cursos\pos\otimiza\aulas\naturais.m' eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); eval( 'if exist(''ex_swarm'',''var''), mauifunc(ex_swarm), end', ''); eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); eval( 'if exist(''colocar'',''var''), mauifunc(colocar), end', ''); eval( 'if exist(''Para'',''var''), mauifunc(Para), end', ''); disp(which('teste_buscarnd')); disp(char(which('teste_buscarnd','-all'))); eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); eval( 'if exist(''terceiro'',''var''), mauifunc(terceiro), end', ''); eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); eval( 'if exist(''dois'',''var''), mauifunc(dois), end', ''); eval( 'if exist(''swarm'',''var''), mauifunc(swarm), end', ''); eval( 'if exist(''melhores'',''var''), mauifunc(melhores), end', ''); disp(which('teste_buscarnd')); disp(char(which('teste_buscarnd','-all'))); eval( 'if exist(''xo'',''var''), mauifunc(xo), end', ''); 0.7413 0.7408 0.7409 0.7415 0.7412 1.2306 -0.7396 -0.2533 eval( 'if exist(''hist'',''var''), mauifunc(hist), end', ''); disp(which('teste_buscarnd')); disp(char(which('teste_buscarnd','-all'))); eval( 'if exist(''toc'',''var''), mauifunc(toc), end', ''); ; teste_buscarnd ??? Undefined function or variable 'teste_buscarnd'. cd(cd) teste_buscarnd tb = 20.3400 ans = 70 edit teste_buscarnd disp(sprintf('%d',feature('SessionTool'))) 0 ; dbstatus dbstack dbstack ; disp(which('teste_buscarnd')); v:\cursos\pos\otimiza\aulas\teste_buscarnd.m mdbstatus 'v:\cursos\pos\otimiza\aulas\teste_buscarnd.m' eval( 'if exist(''figure'',''var''), mauifunc(figure), end', ''); eval( 'if exist(''nb'',''var''), mauifunc(nb), end', ''); Columns 1 through 12 1 4 7 9 10 12 13 14 15 16 17 18 Columns 13 through 24 19 21 22 23 24 25 26 28 29 31 34 35 Columns 25 through 36 36 37 38 39 40 41 42 43 44 45 46 48 Columns 37 through 48 51 52 54 57 58 59 61 63 64 66 67 68 Columns 49 through 60 70 71 72 73 74 75 78 79 80 81 84 85 Columns 61 through 70 86 88 90 91 92 94 95 96 97 98 eval( 'if exist(''for'',''var''), mauifunc(for), end', ''); eval( 'if exist(''tic'',''var''), mauifunc(tic), end', ''); disp(which('teste_buscarnd')); v:\cursos\pos\otimiza\aulas\teste_buscarnd.m clear 'v:\cursos\pos\otimiza\aulas\teste_buscarnd.m' eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); disp(which('teste_buscarnd')); v:\cursos\pos\otimiza\aulas\teste_buscarnd.m clear 'v:\cursos\pos\otimiza\aulas\teste_buscarnd.m' clear functions cd(cd) teste_buscarnd tb = 0.3953 ans = 74 eval( 'if exist(''buscarnd'',''var''), mauifunc(buscarnd), end', ''); disp(which('teste_buscarnd')); v:\cursos\pos\otimiza\aulas\teste_buscarnd.m clear 'v:\cursos\pos\otimiza\aulas\teste_buscarnd.m' eval( 'if exist(''find'',''var''), mauifunc(find), end', ''); eval( 'if exist(''figure'',''var''), mauifunc(figure), end', ''); ; help swarm Hard constrained global optimization using SWARM. [xo,Ot,nS]=swarm(S,x0,ip,isb,Lb,Ub,R,nger,npas,problem,c1,c2) S: objective function x0: inital point ip: (0): no plot (default), (>0) plot figure ip with pause, (<0) plot figure ip isb: isb(i)=1 is i-th variable is bounded, otherwise isb(i)=0 (default = 0) Lb, Ub: lower and upper bound vectors (default = x0*(1+/-2) for plot if isb(i)=0) R: axis vector of the hyperellipse centered in x0 (default = max(0.1*abs(x0+~x0),1)) nger: number of generations or flights (default = 50) npas: number of birds (default = 10) problem: (-1): minimum (default), (1): maximum c1: local search parameter (default = 1) c2: global search parameter (default = 1) xo: optimal point Ot: optimal values of S nS: number of objective function evaluations edit swarm disp(sprintf('%d',feature('SessionTool'))) 0 ; dbstatus dbstack dbstack ; disp(which('swarm')); v:\cursos\pos\otimiza\aulas\swarm.m mdbstatus 'v:\cursos\pos\otimiza\aulas\swarm.m' ; [xo,Ot,nS]=swarm('test9',[1 1],-1,[0 0],[-5 -5],[5 5],5) xo = 3.5844 -1.8481 Ot = 1.5535e-011 nS = 510 [xo,Ot,nS]=swarm('test9',[1 1],-1,[0 0],[-5 -5],[5 5],5) xo = -2.8051 3.1313 Ot = 1.7982e-011 nS = 510 [xo,Ot,nS]=swarm('test9',[1 1],-1,[0 0],[-5 -5],[5 5],5) xo = 3.5864 -1.8519 Ot = 3.6478e-004 nS = 510 [xo,Ot,nS]=swarm('ex_swarm',[0 0],-1,[0 0],[-1 -1],[1 1],2) xo = -0.7393 -0.7398 Ot = -12.0378 nS = 510 [xo,Ot,nS]=swarm('ex_swarm',[0 0],-1,[0 0],[-1 -1],[1 1],2) xo = 0.2553 0.7414 Ot = -13.6631 nS = 510 [xo,Ot,nS]=swarm('ex_swarm',[0 0],-1,[0 0],[-1 -1],[1 1],2) xo = 0.7394 0.7571 Ot = -17.6130 nS = 510 [xo,Ot,nS]=swarm('ex_swarm',[0 0],-1,[0 0],[-1 -1],[1 1],2) xo = 0.7409 1.2306 Ot = -15.8445 nS = 510 type naturais [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],0,1,20,[-1 -1],[1 1],[],[],[],[2 2]) [xo,Ot,nS]=swarm('ex_swarm',[0 0],0,[1 1],[-1 -1],[1 1],[],100,20) % Para achar os dois melhores otimos [xo,Ot,nS]=buscarnd('ex_swarm',[0 0],0,2,20,[-1 -1],[1 1],[],[],[],[2 2]) % Se colocar o terceiro argumento como -1 nos dois algoritmos, entao faz o grafico. tic for i=1:100, [xo,Ot(i),nS]=buscarnd('ex_swarm',[0 0],0,1,20,[-1 -1],[1 1],[],[],[],[2 2]); end tb=toc nb=find(Ot < -17); size(nb,2) figure(1); hist(Ot); legend('buscarnd'); tic for i=1:100, [xo,Ots(i),nS]=swarm('ex_swarm',[0 0],0,[1 1],[-1 -1],[1 1],[],100,20); end ts=toc ns=find(Ots < -17); size(ns,2) figure(2); hist(Ots); legend('swarm'); naturais xo = -0.7395 0.7411 Ot = -14.9991 nS = 581 xo = 0.7411 0.7411 Ot = -17.9602 nS = 2020 xo = 0.7412 0.7412 0.7413 -0.7395 Ot = -17.9601 -14.9991 nS = 1541 tb = 18.9270 ans = 71 ts = 31.0240 ans = 41 quit