funStretchedV

PURPOSE ^

% StretchedV function

SYNOPSIS ^

function [p,dp] = funStretchedV(xx)

DESCRIPTION ^

% StretchedV function
 L. LAURENT -- 20/02/2017 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% StretchedV function
0002 % L. LAURENT -- 20/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)=0
0025 %
0026 %Design space -10<xi<10
0027 
0028 
0029 function [p,dp] = funStretchedV(xx)
0030 
0031 
0032 %constants
0033 a=1/4;
0034 b=50;
0035 c=0.1;
0036 d=1;
0037 
0038 %evaluation and derivatives
0039 sX=size(xx);
0040 %
0041 funG=@(x,y)(x.^2+y.^2);
0042 %
0043 xkp=xx(:,:,2:end);
0044 xk=xx(:,:,1:end-1);
0045 pa=funG(xkp,xk).^a.*(sin(b*funG(xkp,xk).^c)+d).^2;
0046 %
0047 p=sum(pa,3);
0048 
0049 if nargout==2
0050     %
0051     fundG=@(x)2*x;
0052     %
0053     dp=zeros(sX);
0054     %
0055     for itX=1:sX(3)
0056         if itX==1
0057             x=xx(:,:,2);
0058             y=xx(:,:,1);
0059             dp(:,:,itX)=a*fundG(y).*funG(x,y).^(a-1) ...
0060                 .*(sin(b*funG(x,y).^c)+d).^2 ...
0061                 + 2*funG(x,y).^a*c*b.*fundG(y).*funG(x,y).^(c-1) ...
0062                 .*cos(b*funG(x,y).^c).*(sin(b*funG(x,y).^c)+d);
0063         elseif itX==sX(3)
0064             x=xx(:,:,sX(3));
0065             y=xx(:,:,sX(3)-1);
0066             dp(:,:,itX)=a*fundG(x).*funG(x,y).^(a-1) ...
0067                 .*(sin(b*funG(x,y).^c)+d).^2 ...
0068                 + 2*funG(x,y).^a*c*b.*fundG(x).*funG(x,y).^(c-1) ...
0069                 .*cos(b*funG(x,y).^c).*(sin(b*funG(x,y).^c)+d);
0070         else
0071             xk=xx(:,:,itX);
0072             xkp=xx(:,:,itX+1);
0073             xkm=xx(:,:,itX-1);
0074             dp(:,:,itX)=a*fundG(xk).*funG(xk,xkm).^(a-1) ...
0075                 .*(sin(b*funG(xk,xkm).^c)+d).^2 ...
0076                 + 2*funG(xk,xkm).^a*c*b.*fundG(xk).*funG(xk,xkm).^(c-1) ...
0077                 .*cos(b*funG(xk,xkm).^c).*(sin(b*funG(xk,xkm).^c)+d) ...
0078                 +a*fundG(xk).*funG(xkp,xk).^(a-1) ...
0079                 .*(sin(b*funG(xkp,xk).^c)+d).^2 ...
0080                 + 2*funG(xkp,xk).^a*c*b.*fundG(xk).*funG(xkp,xk).^(c-1) ...
0081                 .*cos(b*funG(xkp,xk).^c).*(sin(b*funG(xkp,xk).^c)+d);
0082         end
0083     end
0084 end
0085 end

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