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

    function T = buildBoundaryModels(T)
%buildBoundaryModels build default boundary models
%  T = buildBoundaryModels(T)

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


if isnull(T.ConstraintData)
    % use command-line API
    T = info(T);
    BTree = boundarytree(T);
    T = info(T);
    inputSizes = nfactors(designdev(T));
    [~,Y]=getdata(T);
    switch lower(type(T))
        case 'one-stage'
            if inputSizes==1
                bdryType = 'Range';
            else
                bdryType = 'Convex hull';
            end
            B = CreateBoundary(BTree,bdryType);
            % 10 inputs or more than 2000 observations
            doPairwise = B.NumberOfInputs>10 || (B.NumberOfInputs>2 && size(Y,1)>2000);
            if doPairwise
                pairwise(BTree,B)
            else
                Add(BTree,B);
            end
        case 'two-stage'
            if isGTS( HSModel(T.DesignDev) )
                % make a global convex hull boundary model
                if inputSizes(2)==1
                    bdryType = 'Range';
                else
                    bdryType = 'Convex hull';
                end
                
                B = CreateBoundary(BTree.Global,bdryType);
                % 10 global inputs or more than 2000 tests
                doPairwise = B.NumberOfInputs>10 || (B.NumberOfInputs>2 && size(Y,3)>2000);
                if doPairwise
                    pairwise(BTree.Global,B)
                else
                    Add(BTree.Global,B);
                end
                % add a two-stage global range
                B = BTree.Local.CreateBoundary('Two-stage');
                B.LocalModel = CreateBoundary(B.LocalModel,'Range');
                Add(BTree.Local,B);
            else
                % make a response boundary model
                bdryType = 'Convex hull';
                B = CreateBoundary(BTree,bdryType);
                Add(BTree.Response,B);
            end
        case 'point-by-point'
            B = BTree.Local.CreateBoundary('Point-by-point');
            if inputSizes(1)==1
                bdryType = 'Range';
            else
                bdryType = 'Convex hull';
            end
            B.LocalModel = CreateBoundary(B.LocalModel,bdryType);
            % 10 inputs or any test with more than 2000 elements
            doPairwise = B.LocalModel.NumberOfInputs>10 || (B.LocalModel.NumberOfInputs>2 && any(tsizes(Y)>2000));
            if doPairwise
                pairwiseptbypt(BTree.Local,B);
            else
                % Add point-by-point boundary model to project.
                Add(BTree.Local,B);
            end
    end
    T = info(T);
end

function pairwise(BTree,B)
%pairwise fit pairwise boundary models
n = B.NumberOfInputs;
for i=1:n-1
    for j=i+1:n
        B.ActiveInputs = ismember(1:n,[i j]);
        Add(BTree,B);
    end
end


function pairwiseptbypt(BTree,B)
%pairwise fit pairwise boundary models for point-by-point

n = B.LocalModel.NumberOfInputs;
for i=1:n-1
    for j=i+1:n
        B.LocalModel.ActiveInputs = ismember(1:n,[i j]);
        Add(BTree,B);
    end
end