funSchaffer6

PURPOSE ^

% Schaffer 06 function

SYNOPSIS ^

function [p,dp]=funSchaffer6(xx)

DESCRIPTION ^

% Schaffer 06 function
L. LAURENT -- 27/04/2017 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Schaffer 06 function
0002 %L. LAURENT -- 27/04/2017 -- luc.laurent@lecnam.net
0003 
0004 % sources available here:
0005 % https://bitbucket.org/luclaurent/optigtest/
0006 % https://github.com/luclaurent/optigtest/
0007 
0008 % optiGTest - set of testing functions    A toolbox to easy manipulate functions.
0009 % Copyright (C) 2017  Luc LAURENT <luc.laurent@lecnam.net>
0010 %
0011 % This program is free software: you can redistribute it and/or modify
0012 % it under the terms of the GNU General Public License as published by
0013 % the Free Software Foundation, either version 3 of the License, or
0014 % (at your option) any later version.
0015 %
0016 % This program is distributed in the hope that it will be useful,
0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 % GNU General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU General Public License
0022 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 
0024 %
0025 %global minimum : f(x)=0 for xi=0
0026 %
0027 %Design space: -100<xi<100
0028 %
0029 
0030 
0031 
0032 function [p,dp]=funSchaffer6(xx)
0033 %constants
0034 a=0.5;
0035 b=1;
0036 c=1e-3;
0037 
0038 %evaluation and derivatives
0039 xi=xx(:,:,1:end-1);
0040 xii=xx(:,:,2:end);
0041 %
0042 xA=xii.^2+xi.^2;
0043 %
0044 sqA=sqrt(xA);
0045 sA=sin(sqA);
0046 pA=sA.^2-a;
0047 %
0048 pB=b+c*xA.^2;
0049 %
0050 pt=pA./pB;
0051 %
0052 p=sum(a+pt,3);
0053 %
0054 if nargout==2
0055     %
0056     dp=zeros(size(xx));
0057     %
0058     cA=cos(sqA);
0059     %
0060     dp(:,:,1)=(2*xi(:,:,1)./sqA(:,:,1).*sA(:,:,1).*cA(:,:,1).*pB(:,:,1)...
0061         -4*c*xi(:,:,1).*xA(:,:,1).*pA(:,:,1))./pB(:,:,1).^2;
0062     %
0063     dp(:,:,end)=(2*xii(:,:,end)./sqA(:,:,end).*sA(:,:,end).*cA(:,:,end).*pB(:,:,end)...
0064         -4*c*xii(:,:,end).*xA(:,:,end).*pA(:,:,end))./pB(:,:,end).^2;
0065     %
0066     dp(:,:,2:end-1)=(2*xi(:,:,2:end)./sqA(:,:,2:end).*sA(:,:,2:end).*cA(:,:,2:end).*pB(:,:,2:end)...
0067         -4*c*xi(:,:,2:end).*xA(:,:,2:end).*pA(:,:,2:end))./pB(:,:,2:end).^2 ...
0068         +(2*xii(:,:,1:end-1)./sqA(:,:,1:end-1).*sA(:,:,1:end-1).*cA(:,:,1:end-1).*pB(:,:,1:end-1)...
0069         -4*c*xii(:,:,1:end-1).*xA(:,:,1:end-1).*pA(:,:,1:end-1))./pB(:,:,1:end-1).^2;
0070 end

Generated on Tue 28-May-2019 16:00:34 by m2html © 2005