funWatson

PURPOSE ^

% Watson function

SYNOPSIS ^

function [p,dp] = funWatson(xx)

DESCRIPTION ^

% Watson function
 L. LAURENT -- 27/02/2017 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Watson function
0002 % L. LAURENT -- 27/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.0158,1.012,-0.2329,1.26,-1.513,0.9928)=0.002288
0025 %
0026 %Design space 0.25<xi<10
0027 
0028 %% NEED TO BE FIXED
0029 
0030 function [p,dp] = funWatson(xx)
0031 
0032 
0033 
0034 %constants
0035 a=29;
0036 b=4;
0037 c=5;
0038 d=@(i) i/a;
0039 
0040 %evaluation and derivatives
0041 %
0042 liJ=reshape(0:b,1,1,[]);
0043 liL=reshape(0:c,1,1,[]);
0044 %
0045 sX=size(xx);
0046 %
0047 pp=zeros(sX(1),sX(2),a);
0048 for itI=0:a
0049     pA=(liJ-1).*d(itI).^liJ.*xx(:,:,1:b+1);
0050     pB=d(itI).^liL.*xx(:,:,1:c+1);
0051     pp(:,:,itI+1)=sum(pA,3)-sum(pB,3).^2-1;
0052 end
0053 %
0054 p=sum(pp.^2,3)+xx(:,:,1).^2;
0055 
0056 if nargout==2
0057     %
0058     dp=zeros(sX);
0059     pdp=zeros(sX(1),sX(2),a);
0060     %
0061     for itI=0:a
0062         pB=d(itI).^liL.*xx(:,:,1:c+1);
0063         pdp(:,:,itI+1)=-pp(:,:,itI+1).*(1+2*sum(pB,3));
0064     end
0065     dp(:,:,1)=2*xx(:,:,1)+2*sum(pdp,3);
0066     %
0067     pdp=zeros(sX(1),sX(2),a);
0068     %
0069     for itD=2:sX(3)
0070         for itI=0:a
0071             pB=d(itI).^liL.*xx(:,:,1:c+1);
0072             pdp(:,:,itI+1)=pp(:,:,itI+1).*d(itI).^(itD-1).*(itD-2-2*sum(pB,3));
0073         end
0074         dp(:,:,itD)=2*sum(pdp,3);
0075     end
0076     
0077 end
0078 end
0079

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