% Schwefel 6 function L. LAURENT -- 19/02/2017 -- luc.laurent@lecnam.net
0001 %% Schwefel 6 function 0002 % L. LAURENT -- 19/02/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 %1 minimum global: f(0,...,0)=0 0025 % 0026 %Design space -100<xi<100 0027 0028 0029 function [p,dp] = funSchwefel06(xx) 0030 0031 %constants 0032 a=2; 0033 b=5; 0034 c=7; 0035 0036 %evaluation and derivatives 0037 x=xx(:,:,1); 0038 y=xx(:,:,2); 0039 pa=x+a*y-c; 0040 pb=a*x+y-b; 0041 % 0042 pTmp=zeros(size(xx)); 0043 pTmp(:,:,1)=pa; 0044 pTmp(:,:,2)=pb; 0045 % 0046 if nargout==1 0047 p=max(abs(pTmp),[],3); 0048 else 0049 [p,Ip]=max(abs(pTmp),[],3); 0050 end 0051 0052 if nargout==2 0053 % 0054 dp=zeros(size(xx)); 0055 % 0056 spa=sign(pa); 0057 spb=sign(pb); 0058 % 0059 dpX(:,:,1)=spa; 0060 dpX(:,:,2)=a*spb; 0061 dpY(:,:,1)=a*spa; 0062 dpY(:,:,2)=spb; 0063 %compute linear index 0064 sX=size(xx); 0065 rowSub=(1:sX(1))'; 0066 colSub=1:sX(2); 0067 LI=sub2ind(sX,rowSub(:,ones(1,sX(2))),colSub(ones(1,sX(1)),:),Ip); 0068 % 0069 dp(:,:,1)=dpX(LI); 0070 dp(:,:,2)=dpY(LI); 0071 end 0072 end