% Ackley's function 4 (Modified Ackley Function) L. LAURENT -- 31/10/2016 -- luc.laurent@lecnam.net
0001 %% Ackley's function 4 (Modified Ackley Function) 0002 %L. LAURENT -- 31/10/2016 -- 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 %numerous local minima 0026 %xx global minimum : UNDEFINED 0027 % in dimension 2: x{-1.479252, -0.739807), (1.479252, -0.739807)} >> f(x)=-3.917275 0028 % 0029 %design space -35<xi<35 (small range -2<xi<2) 0030 0031 0032 0033 function [p,dp]=funAckley4(xx) 0034 0035 %constants 0036 a=0.2; 0037 b=3; 0038 c=2; 0039 0040 %number of variables 0041 nbvar=size(xx,3); 0042 0043 %responses and derivatives 0044 ex1=exp(-a); 0045 normP=zeros(size(xx,1),size(xx,2),nbvar-1); 0046 for itV=1:nbvar-1 0047 normP(:,:,itV)=sqrt(xx(:,:,itV).^2+xx(:,:,itV+1).^2); 0048 end 0049 cx=cos(c*xx(:,:,1:end-1)); 0050 sx=sin(c*xx(:,:,2:end)); 0051 p=sum(ex1.*normP+b*(cx+sx),3); 0052 0053 0054 if nargout==2 0055 dp=zeros(size(xx)); 0056 for ii=1:nbvar 0057 if ii==1 0058 dp(:,:,ii)=ex1*xx(:,:,1)./normP(:,:,1)-c*b*sin(c*xx(:,:,1)); 0059 elseif ii==nbvar 0060 dp(:,:,ii)=ex1*xx(:,:,nbvar)./normP(:,:,end)+c*b*cos(c*xx(:,:,nbvar)); 0061 else 0062 dp(:,:,ii)=ex1*xx(:,:,ii)./normP(:,:,ii)-c*b*sin(c*xx(:,:,ii))... 0063 +ex1*xx(:,:,ii+1)./normP(:,:,ii+1)+c*b*cos(c*xx(:,:,ii+1)); 0064 end 0065 end 0066 end 0067 end