funPenalty1

PURPOSE ^

% Penalty 1 function

SYNOPSIS ^

function [p,dp]=funPenalty1(xx)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Penalty 1 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=-1
0026 %
0027 %Design space: -50<xi<50
0028 %
0029 
0030 
0031 
0032 function [p,dp]=funPenalty1(xx)
0033 %constants
0034 a=pi/30;
0035 b=10;
0036 c=pi;
0037 d=1;
0038 e=100;
0039 f=4;
0040 
0041 %evaluation and derivatives
0042 y=d+1/f*(xx+d);
0043 %
0044 pa=sin(c*y(:,:,1));
0045 pb=y(:,:,1:end-1)-d;
0046 sc=sin(c*y(:,:,2:end));
0047 pc=d+b*sc.^2;
0048 pd=y(:,:,end)-d;
0049 %
0050 u=zeros(size(xx));
0051 IXb=abs(xx)>b;
0052 u(IXb)=e*(abs(xx(IXb))-b).^f;
0053 %
0054 p=a*(b*pa.^2+sum(pb.^2.*pc,3)+pd.^2)+sum(u,3);
0055 %p=a*pd.^2;
0056 %keyboard
0057 %
0058 if nargout==2
0059     %
0060     dp=zeros(size(xx));
0061     %
0062     du=zeros(size(xx));
0063     du(IXb)=f*e*sign(xx(IXb)).*(abs(xx(IXb))-b).^(f-1);
0064     %
0065     ppa=cos(c*y(:,:,1));
0066     cc=cos(c*y(:,:,2:end));
0067     %
0068     dp(:,:,1)=2*a*b*c/f.*pa.*ppa...
0069         +2*a/f*pb(:,:,1).*pc(:,:,1)...
0070         +du(:,:,1);
0071     dp(:,:,end)=2*a*b*c/f.*sc(:,:,end).*cc(:,:,end).*pb(:,:,end).^2 ...
0072         +2*a/f*pd...
0073         +du(:,:,end);
0074     dp(:,:,2:end-1)=2*a*b*c/f.*sc(:,:,1:end-1).*cc(:,:,1:end-1).*pb(:,:,1:end-1).^2 ...
0075         +2*a/f*pb(:,:,2:end).*pc(:,:,2:end)...
0076         +du(:,:,2:end-1);
0077 end

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