funDejong

PURPOSE ^

% De Jong function

SYNOPSIS ^

function [p,dp,infos]=funDejong(xx,dim)

DESCRIPTION ^

% De Jong function
L. LAURENT -- 21/02/2012 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% De Jong function
0002 %L. LAURENT -- 21/02/2012 -- 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 %1 global minimum : x=(0,0,...,0) >> f(x)=0
0026 %
0027 %design space -5.12<xi<5.12
0028 
0029 function [p,dp,infos]=funDejong(xx,dim)
0030 
0031 coef=10;
0032 
0033 
0034 % demo mode
0035 dem=false;
0036 if nargin==0
0037     pas=50;
0038     borne=5.12;
0039     [x,y]=meshgrid(linspace(-borne,borne,pas));
0040     xx=zeros(pas,pas,2);
0041     xx(:,:,1)=x;xx(:,:,2)=y;
0042     dem=true;
0043 end
0044 if ~isempty(xx)
0045     % number of design variables
0046     nbvar=size(xx,3);
0047     
0048     if nbvar==1
0049         if size(xx,2)==2
0050             xxx=xx(:,1);yyy=xx(:,2);
0051         elseif size(xx,1)==2
0052             xxx=xx(:,2);yyy=xx(:,1);
0053         else
0054             error(['Wrong input variables ',mfilename]);
0055         end
0056         p=xxx.^2+yyy.^2;
0057         if nargout==2||dem
0058             dp(:,:,1)=2*xxx;
0059             dp(:,:,2)=2*yyy;
0060         end
0061     else
0062         cal=xx.^2;
0063         p=sum(cal,3);
0064         if nargout==2||dem
0065             dp=2*xx;
0066         end
0067     end
0068 else
0069     if nargin==2
0070         nbvar=dim;
0071     end
0072     p=[];
0073     dp=[];
0074 end
0075 % output: information about the function
0076 if nargout==3
0077     pts=zeros(1,nbvar);
0078     infos.min_glob.X=pts;
0079     infos.min_glob.Z=zeros(1,nbvar);
0080     infos.min_loc.Z=pts;
0081     infos.min_loc.X=zeros(1,nbvar);
0082 end
0083 
0084 % demo mode
0085 if nargin==0
0086     figure
0087     subplot(1,3,1)
0088     surf(x,y,p);
0089     axis('tight','square')
0090     xlabel('x'), ylabel('y'), title('De Jong')
0091     subplot(1,3,2)
0092     surf(x,y,dp(:,:,1));
0093     axis('tight','square')
0094     xlabel('x'), ylabel('y'), title('Grad. X De Jong')
0095     subplot(1,3,3)
0096     surf(x,y,dp(:,:,2));
0097     axis('tight','square')
0098     xlabel('x'), ylabel('y'), title('Grad. Y De Jong')
0099 end
0100 end
0101

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