function [ minf, delta, point ] = best_nearby( delta, point, prevbest, nvars ) % BEST_NEARBY - Given a point look for a better one nearby, one coord at a time % % Written by: % -- % John L. Weatherwax 2004-10-08 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- global funevals; minf = prevbest; z = point; for i=1:nvars, % Increase this coordinate direction: z(i) = point(i)+delta(i); % Look for improvement in minimization: funevals=funevals+1; %ftmp = f(z); ftmp = banana(z); if( ftmp < minf ) minf=ftmp; else % No improvement; decrease this coordinate direction: delta(i) = -delta(i); z(i) = point(i)+delta(i); % Look for improvement: funevals=funevals+1; %ftmp = f(z); ftmp = banana(z); if( ftmp < minf ) minf=ftmp; else z(i)=point(i); end end end point=z;