% % 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'); x0 = 10*randn(2,1); % seems to have a final location that is inside the desired domain n_random_starts = 5; for ii=1:n_random_starts, sol_opt = bfgswopt( x0, wfn, 0.001 ); % seems to have a very large domain of convergence sol_opt = steep( x0, wfn, 0.001 ); fn_opt = wfn( sol_opt ); fprintf('%2d: x_0=%6.2f y_0= %6.2f x_f= %8.2f, y_f= %8.2f, fn value= %8.3f\n',ii,x0(1),x0(2),sol_opt(1),sol_opt(2),fn_opt); x0 = sol_opt; end