evalObj

PURPOSE ^

% Method of optiGTest class

SYNOPSIS ^

function [ZZ,GZ,GZreshape]=evalObj(obj,XX,num)

DESCRIPTION ^

% Method of optiGTest class
 L. LAURENT --  15/04/2018 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Method of optiGTest class
0002 % L. LAURENT --  15/04/2018 -- 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) 2018  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 %% evaluate the objective function(s)
0025 % INPUTS:
0026 %  - XX: sample points on which the function(s) will be evaluate [optional]
0027 %  - num: number of the requested function(s) in the case of multiobjective problem [optional]
0028 % OUTPUTS:
0029 %  - ZZ, GZ: responses and gradients of the function(s) stored in cells (in the case of one requested function or monoobjective problem no cell is used)
0030 %  - GZrehape: specific storage of the gradients for meshgrid
0031 
0032 function [ZZ,GZ,GZreshape]=evalObj(obj,XX,num)
0033 %default values
0034 Xrun=obj.Xeval;
0035 numOk=[];
0036 if nargin>2, if ~isempty(num);numOk=num;end, end
0037 %
0038 if nargin>1
0039     if ~isempty(XX)
0040         Xrun=obj.prepX(XX);
0041     end
0042 end
0043 %
0044 %specific objective function(s)
0045 if ~isempty(numOk)
0046     cellObj=obj.funObj(numOk);
0047 else
0048     cellObj=obj.funObj;
0049 end
0050 %
0051 nbF=numel(cellObj);
0052 ZZtmp=cell(1,nbF);
0053 if nargout>1;GZtmp=cell(1,nbF);end
0054 %evaluate (all) objective function(s)
0055 for itF=1:numel(cellObj)
0056     if nargout>1
0057         [ZZtmp{itF},GZtmp{itF}]=feval(['fun' cellObj{itF}],Xrun);
0058     else
0059         [ZZtmp{itF}]=feval(['fun' cellObj{itF}],Xrun);
0060     end
0061 end
0062 %reshape data
0063 if nbF==1
0064     ZZ=ZZtmp{1};
0065     if nargout>1
0066         GZ=GZtmp{1};
0067     end
0068 else
0069     ZZ=ZZtmp;
0070     if nargout>1
0071         GZ=GZtmp;
0072     end
0073 end
0074 if nargout>2
0075     if nbF==1
0076         GZreshape=reshape(GZ,[],size(GZ,3));
0077     else
0078         GZreshape=cell(1,nbF);
0079         for itF=1:numel(cellObj)
0080             GZreshape{itF}=reshape(GZ{itF},[],size(GZ{itF},3));
0081         end
0082     end
0083 end
0084 end

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