www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/multimodel.m

    function [Map,BdryModel]= multimodel(T)
%MULTIMODEL make multimodel for testplan
%
% [Map,BdryModel]= multimodel(T)

%  Copyright 2006-2011 The MathWorks, Inc.



TS = HSModel(T.DesignDev);

% use boundary model from test plan
BdryModel = BoundaryModel(T,TS);
if isempty(BdryModel)
    % make a point-by-point range boundary model
    if isnull(T.ConstraintData)
        broot = MakeBdryData( T );
        T = info(T);
    else
        broot = T.ConstraintData;
    end
    % make new point-by-point boundary mode
    bdev = makeBdryNode(info(broot),1);
    con = newconstraint( bdev );
    con = conswitch(con);
    clocal = getlocal(con);
    % range constraint
    clocal = conrange(getInputFactors(clocal));
    con = setlocal(con,clocal);
    % set and fit constraint in bdev
    opts = getFitOptions(con,'all');
    bdev = setupConstraint(bdev,con,opts);
    [bdev,ok] = fitConstraint(bdev,'all');

    % add to best
    addbest(info(Parent(bdev)),address(bdev));
    
    % now get boundary model
    BdryModel = BoundaryModel(T,TS);
end

if isa(BdryModel,'conswitch')
    % keep last of nonunique points
    X = getdata(T,'X');
    [~,KeepLast]= uniqueFilters(X{end});
    BdryModel = selectModels(BdryModel,KeepLast); 
end

p = children(T,@bestmdev);
Map = cell(1,length(p));
for i = 1:length(p)
    if p{i}==0
        % use the first local model if there is not a best one
        p(i) = children(T,i,@children,1);
    end
    Map{i} = multimodel(p{i}.info);
end
% remove empty multimodels
Map(cellfun(@isempty,Map)) = [];

if ~isempty(Map)
    % share constraints
    [Map{:}] = shareConstraints(Map{:});
end