funDixon

PURPOSE ^

% Dixon & Price function

SYNOPSIS ^

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

DESCRIPTION ^

% Dixon & Price function
 L. LAURENT -- 16/09/2011 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Dixon & Price function
0002 % L. LAURENT -- 16/09/2011 -- 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 %Design space: -10<xi<10
0026 
0027 
0028 
0029 function [p,dp,infos] = funDixon(xx,dim)
0030 % demo mode
0031 dem=false;
0032 if nargin==0
0033     pas=50;
0034     borne=10;
0035     [x,y]=meshgrid(linspace(-borne,borne,pas));
0036     xx=zeros(pas,pas,2);
0037     xx(:,:,1)=x;xx(:,:,2)=y;
0038     dem=true;
0039 end
0040 if ~isempty(xx)
0041     % number of design variables
0042     nbvar=size(xx,3);
0043     
0044     if nbvar==1
0045         error(['Wrong input variables ',mfilename]);
0046     else
0047         p=(xx(:,:,1)-1).^2;
0048         for iter=2:nbvar
0049             p=p+iter*(2*xx(:,:,iter).^2-xx(:,:,iter-1)).^2;
0050         end
0051         
0052         if nargout==2||dem
0053             dp=zeros(size(xx));
0054             for iter=1:nbvar
0055                 if iter==1
0056                     dp(:,:,iter)=2*(xx(:,:,iter)-1)-4*(2*xx(:,:,iter+1).^2-xx(:,:,iter));
0057                 elseif iter==nbvar
0058                     dp(:,:,iter)=iter*8*xx(:,:,iter).*(2*xx(:,:,iter).^2-xx(:,:,iter-1));
0059                 else
0060                     dp(:,:,iter)=iter*8*xx(:,:,iter).*(2*xx(:,:,iter).^2-xx(:,:,iter-1))...
0061                         -2*iter*(2*xx(:,:,iter+1).^2-xx(:,:,iter));
0062                     
0063                 end
0064             end
0065         end
0066         
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=NaN;
0078     infos.min_glob.X=pts;
0079     infos.min_glob.Z=NaN;
0080     infos.min_loc.Z=NaN;
0081     infos.min_loc.X=pts;
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('Dixon & Price')
0091     subplot(1,3,2)
0092     surf(x,y,dp(:,:,1));
0093     axis('tight','square')
0094     xlabel('x'), ylabel('y'), title('Grad. X Dixon & Price')
0095     subplot(1,3,3)
0096     surf(x,y,dp(:,:,2));
0097     axis('tight','square')
0098     xlabel('x'), ylabel('y'), title('Grad. Y Dixon & Price')
0099 end
0100 end

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