% Hansen function L. LAURENT -- 16/11/2016 -- luc.laurent@lecnam.net
0001 %% Hansen function 0002 %L. LAURENT -- 16/11/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 %global minimum : f(x1,x2)=-176.5418 for 0026 % (x1,x2)={(-7.589893, -7.708314), (-7.589893, -1.425128), 0027 % (-7.589893, 4.858057), (-1.306708, -7.708314), 0028 % (-1.306708, 4.858057), ( 4.976478, 4.858057), 0029 % ( 4.976478, -1.425128), ( 4.976478, -7.708314)} 0030 % 0031 %Design space: -10<xi<10 0032 0033 0034 function [p,dp]=funHansen(xx) 0035 %constants 0036 a=4; 0037 b=1; 0038 c=2; 0039 0040 %variables 0041 xxx=xx(:,:,1); 0042 yyy=xx(:,:,2); 0043 0044 %evaluation and derivatives 0045 ii=reshape(0:a,1,1,a+1); 0046 pa=bsxfun(@times,ii,xxx); 0047 pb=bsxfun(@plus,ii,pa); 0048 pc=bsxfun(@times,(ii+c),yyy); 0049 pd=bsxfun(@plus,ii,pc); 0050 pe=bsxfun(@times,(ii+b),cos(pb+b)); 0051 pf=bsxfun(@times,(ii+b),cos(pd+b)); 0052 % 0053 pta=sum(pe,3); 0054 ptb=sum(pf,3); 0055 p=pta.*ptb; 0056 0057 if nargout==2 0058 pg=bsxfun(@times,ii.*(ii+b),sin(pb+b)); 0059 ph=bsxfun(@times,(ii+c).*(ii+b),sin(pd+b)); 0060 % 0061 dp(:,:,1)=-sum(pg,3).*ptb; 0062 dp(:,:,2)=-sum(ph,3).*pta; 0063 end 0064 end