function fprimeprime=testfunctionprimeprime(x,funnum) % TESTFUNCTIONPRIMEPRIME - The second derivative of various test functions for optimization % These are the second derivatives of the test functions that appear in Appendix I. % Set funnum to the function you want to use. % funnum=17 is the MOO function and is not plotted % % From the book: % Practical Genetic Algorithms % by Haupt & Haupt. % % Epage: 250 % % 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. % %----- % check inputs: assert( prod(size(x))==length(x), 'input must be a vector (and not a matrix)' ); % make sure our input is a row vector x = x(:)'; switch funnum case 1, assert( false, 'not yet implemented' ); f = abs(x)+cos(x); case 2, assert( false, 'not yet implemented' ); f = abs(x)+sin(x); case 3, assert( false, 'not yet implemented' ); fprime = x(:,1).^2 + x(:,2).^2; case 4, assert( false, 'not yet implemented' ); fprime = 100*(x(:,2).^2 - x(:,1)).^2 + (1-x(:,1)).^2; case 5, assert( false, 'not yet implemented' ); fprime = sum( abs(x')-10*cos(sqrt(abs(10*x'))) )'; case 6, assert( false, 'not yet implemented' ); fprime = (x.^2 + x).*cos(x); case 7, fprimeprime = zeros(2,2); fprimeprime(1,1) = 8*cos(4*x(1)) + 16*x(1)*sin(4*x(1)); fprimeprime(1,2) = 0.; fprimeprime(2,1) = 0.; fprimeprime(2,2) = 4.4*cos(2*x(2)) - 4.4*x(2)*sin(2*x(2)); case 8, assert( false, 'not yet implemented' ); fprime = x(:,2).*sin(4*x(:,1))+1.1*x(:,2).*sin(2*x(:,2)); case 9, assert( false, 'not yet implemented' ); f(:,1) = x(:,1).^4 + 2*x(:,2).^4 + randn(length(x(:,1)),1); case 10, fprimeprime = zeros(2,2); fprimeprime(1,1) = 2 + 40*(pi^2)*cos(2*pi*x(1)); fprimeprime(1,2) = 0; fprimeprime(2,1) = 0; fprimeprime(2,2) = 2 + 40*(pi^2)*cos(2*pi*x(2)); case 11, fprimeprime = zeros(2,2); fprimeprime(1,1) = 1/2000. + cos(x(1))*cos(x(2)); fprimeprime(1,2) = -sin(x(1))*sin(x(2)); fprimeprime(2,1) = fprimeprime(1,2); fprimeprime(2,2) = 1/2000. - cos(x(1))*cos(x(2)); case 12, assert( false, 'not yet implemented' ); f(:,1) = 0.5+(sin(sqrt(x(:,1).^2 + x(:,2).^2).^2)-0.5)./(1+0.1*(x(:,1).^2+x(:,2).^2)); case 13, assert( false, 'not yet implemented' ); aa = x(:,1).^2 + x(:,2).^2; bb = ((x(:,1)+0.5).^2 + x(:,2).^2).^0.1; f(:,1) = aa.^0.25.*sin(30*bb).^2 + abs(x(:,1))+abs(x(:,2)); case 14, assert( false, 'not yet implemented' ); f(:,1) = besselj(0,x(:,1).^2+x(:,2).^2)+abs(1-x(:,1))/10+abs(1-x(:,2))/10; case 15, assert( false, 'not yet implemented' ); f(:,1) = -exp(0.2*sqrt((x(:,1)-1).^2+(x(:,2)-1).^2)+(cos(2*x(:,1))+sin(2*x(:,1)))); case 16, assert( false, 'not yet implemented' ); f(:,1) = -x(:,1).*sin(sqrt(abs(x(:,1)-(x(:,2)+9))))-(x(:,2)+9).*sin(sqrt(abs(x(:,2)+0.5*x(:,1)+9))); case 17, assert( false, 'not yet implemented' ); x=x+1; f(:,1) = (x(:,1)+x(:,2).^2 + sqrt(x(:,3))+ 1.0./x(:,4))/8.5; f(:,2) = (1./x(:,1)+1./x(:,2)+x(:,3)+x(:,4))/6; otherwise error( 'unknown function' ); end