www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmodel/ModelClasses.m

    
function ud= ModelClasses(mdl,crit)
%MODELCLASSES  return list of MBC Toolbox model classes
%
% ud=MODELCLASSES(mdl,crit);
%
% Inputs 
%  mdl model
%  crit (optional): 0 => return all (default)
%                   1 => return only linear
%                   2 => return only non-linear
%                   4 => 2nd stage models (obsolete return all)
%                   8 => Expand linear models to return one option per
%                        linear type
%
% Output Structure
%   ud.fCreate        Class constructor function handle: fCreate('nfactors',nf);
%   ud.DisplayName    Display String for Model
%   ud.Group          isa(m,ud.Group{i})

%  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin<2
    % return all models
    crit=0;
end

% Response features is obsolete (was isRF=bitand(crit,4));


nf=nfactors(mdl);

ExpandLinear = bitand(crit,8);
if ExpandLinear
    % list of linear models is defined here
    ud = xregLinearClasses;
    h = ud;
    for i=1:length(ud.Group)
        % expand hybrid rbfs for each linear model
        h.Group{i} = 'xreghybridrbf';
        fLin = ud.fCreate{i};
        h.fCreate{i} = @(prop,nf) xreghybridrbf(prop,nf,fLin);
        h.DisplayName{i} =  [h.DisplayName{i} ' Hybrid RBF'];
    end
else
    % the choice of which linear model is made lower down in GUI
    ud.Group=      {'xreglinear'};
    ud.fCreate={@xregcubic};
    ud.DisplayName=      {'Linear models'};

    % hybridrbf - use the default hybrid rbf
    h.Group = {'xreghybridrbf'};
    h.fCreate = {@xreghybridrbf};
    h.DisplayName= {'Hybrid RBF'};
end

% built-in classes
%                    Linear           RBF         Hybrid RBF    Multi-linear   Neural Net
ud.Group=      [ud.Group, {'xreggpr','xregrbf'} ,h.Group {'xregmultilin','xregnnet','xreginterprbf'}];
ud.fCreate=[ud.fCreate {@xreggpr,@xregrbf} ,h.fCreate  {@xregmultilin,@xregnnet,@xreginterprbf}];
ud.DisplayName=      [ud.DisplayName {'Gaussian Process Model','Radial basis function'},h.DisplayName,...
    {'Multiple linear models','Neural network','Interpolating RBF'}];

if nf==1
	% add free knot splines if there is one factor
	ud.Group{end+1}= 'xregunispline';
	ud.fCreate{end+1}=@xregunispline;
	ud.DisplayName{end+1}= 'Free knot spline';
end

% user-defined stage models
ud.usermodels= getmodellist(xregusermod,nf);
if ~isempty(ud.usermodels)
    % add xregusermod models
	ud.Group{end+1}= 'xregusermod';
	ud.fCreate{end+1}=@xregusermod;
	ud.DisplayName{end+1}= 'User-defined models';
end

% transient models
ud.transient= getmodellist(xregtransient,nf);
if ~isempty(ud.transient)
    % remove xregtransient models
	ud.Group{end+1}= 'xregtransient';
	ud.fCreate{end+1}=@xregtransient;
	ud.DisplayName{end+1}= 'Transient models';

end

% structure defining additional classes from extensions
ext = mbcextensions.Extensions.Model;
mdl_ext= ext.ModelClasses;
if ~isempty(mdl_ext) && ~isfield(mdl_ext,'fCreate')
    % upgrade to new fieldnames
    [mdl_ext.fCreate] = deal(mdl_ext.createclassfuncs);
    [mdl_ext.DisplayName] = deal(mdl_ext.classnames);
    [mdl_ext.Group] = deal(mdl_ext.classfuncs);
end


N_extmdl=length(mdl_ext);
% Loop over extensions and add the ones which fit the circumstances
for n=1:N_extmdl
   TAKE_MODEL= false;
   if (mdl_ext(n).minNF==0 && mdl_ext(n).maxNF==0) && any(nf==mdl_ext(n).exactNF)   % use exactNF
       TAKE_MODEL=true;
   elseif (nf>=mdl_ext(n).minNF && nf<=mdl_ext(n).maxNF)
       TAKE_MODEL=true;
   end
   if TAKE_MODEL
      ud.Group=[ud.Group {mdl_ext(n).Group}];
      ud.fCreate=[ud.fCreate {mdl_ext(n).fCreate}];
      ud.DisplayName=[ud.DisplayName {mdl_ext(n).DisplayName}];
   end
end


if bitand(crit,1) || bitand(crit,2)
	% strip out linear (crit==1) or nonlinear (crit==2)
   lin=false(length(ud.DisplayName),1);
   for n=1:length(lin)
      lin(n)=islinear(feval(ud.fCreate{n}));
   end
   if bitand(crit,2)
      lin=~lin;
   end
   ud.Group=ud.Group(lin);
   ud.fCreate=ud.fCreate(lin);
   ud.DisplayName=ud.DisplayName(lin);
end