funPinter

PURPOSE ^

% Pinter function

SYNOPSIS ^

function [p,dp]=funPinter(xx)

DESCRIPTION ^

% Pinter function
L. LAURENT -- 21/03/2017 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Pinter function
0002 %L. LAURENT -- 21/03/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: -10<xi<10
0028 %
0029 
0030 function [p,dp]=funPinter(xx)
0031 %constants
0032 a=20;
0033 b=2;
0034 c=3;
0035 d=1;
0036 
0037 %evaluation and derivatives
0038 nbvar=size(xx,3);
0039 %
0040 xxm=xx(:,:,[end 1:end 1]);
0041 %
0042 A=xxm(:,:,1:end-2).*sin(xx)+sin(xxm(:,:,3:end));
0043 B=xxm(:,:,1:end-2).^2-b*xx+c*xxm(:,:,3:end)-cos(xx)+d;
0044 %
0045 listI=reshape(1:nbvar,1,1,nbvar);
0046 %
0047 pa=listI.*xx.^2;
0048 pb=a*listI.*sin(A).^2;
0049 pc=1+listI.*B.^2;
0050 pd=listI.*log10(pc);
0051 %
0052 p=sum(pa+pb+pd,3);
0053 %
0054 if nargout==2
0055     %
0056     dp=2*listI.*xx;
0057     %
0058     Akm=cos(xx);
0059     Ak=xxm(:,:,1:end-2).*cos(xx);
0060     Akp=sin(xxm(:,:,3:end));
0061     %
0062     Bkm=c;
0063     Bk=sin(xx)-b;
0064     Bkp=2*xx;
0065     %
0066     dp(:,:,1)=dp(:,:,1)...
0067         +2*a*Ak(:,:,1).*cos(A(:,:,1)).*sin(A(:,:,1))...
0068         +4*a*Akp(:,:,1).*cos(A(:,:,2)).*sin(A(:,:,2))...
0069         +2*nbvar*a*Akm(:,:,1).*cos(A(:,:,end)).*sin(A(:,:,end))...
0070         +2*B(:,:,1).*Bk(:,:,1)./(log(10)*pc(:,:,1))...
0071         +8*B(:,:,2).*Bkp(:,:,1)./(log(10)*pc(:,:,2))...
0072         +2*nbvar^2*B(:,:,end).*Bkm./(log(10)*pc(:,:,end));
0073     %
0074     dp(:,:,end)=dp(:,:,end)...
0075         +2*a*nbvar*Ak(:,:,end).*cos(A(:,:,end)).*sin(A(:,:,end))...
0076         +2*a*Akp(:,:,end).*cos(A(:,:,1)).*sin(A(:,:,1))...
0077         +2*a*(nbvar-1)*Akm(:,:,end).*cos(A(:,:,end-1)).*sin(A(:,:,end-1))...
0078         +2*nbvar^2*Bk(:,:,end).*B(:,:,end)./(log(10)*pc(:,:,end))...
0079         +2*Bkp(:,:,end).*B(:,:,1)./(log(10)*pc(:,:,1))...
0080         +2*(nbvar-1)^2*Bkm.*B(:,:,end-1)./(log(10)*pc(:,:,end-1));
0081     %
0082     dp(:,:,2:end-1)=dp(:,:,2:end-1)...
0083         +2*a*listI(:,:,2:end-1).*Ak(:,:,2:end-1).*cos(A(:,:,2:end-1)).*sin(A(:,:,2:end-1))...
0084         +2*a*listI(:,:,3:end).*Akp(:,:,2:end-1).*cos(A(:,:,3:end)).*sin(A(:,:,3:end))...
0085         +2*a*listI(:,:,1:end-2).*Akm(:,:,2:end-1).*cos(A(:,:,1:end-2)).*sin(A(:,:,1:end-2))...
0086         +2*listI(:,:,2:end-1).^2.*Bk(:,:,2:end-1).*B(:,:,2:end-1)./(log(10)*pc(:,:,2:end-1))...
0087         +2*listI(:,:,3:end).^2.*Bkp(:,:,2:end-1).*B(:,:,3:end)./(log(10)*pc(:,:,3:end))...
0088         +2*listI(:,:,1:end-2).^2.*Bkm.*B(:,:,1:end-2)./(log(10)*pc(:,:,1:end-2));
0089         
0090 end

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