% % Examples From the book: % % Practical Genetic Algorithms % by Haupt & Haupt. % % Epage: 44 % % Written by: % -- % John L. Weatherwax 2006-08-28 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; clc; clear all; randn('seed',0); % pick a function to study: % funnum = 10; %plot_test_functions % display this function wfn = @(x) fn_wrap(x,funnum); addpath('../SHIP'); n_random_starts = 25; for ii=1:n_random_starts, x0 = 10.*randn( 2, 1 ); % get a random initial guess around (0,0) sol_opt = steep( x0, wfn, 0.00001 ); fn_opt = wfn( sol_opt ); fprintf('x_0=%7.2f y_0= %7.2f x_f= %10.2f, y_f= %10.2f, fn= %10.3f\n',x0(1),x0(2),sol_opt(1),sol_opt(2),fn_opt); end