www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/+mbcboundary/TwoStageTree.m
classdef TwoStageTree < mbcutils.pointerinterface %MBCBOUNDARY.TWOSTAGETREE root boundary tree class in two-stage test plans % You access the boundary tree from the Boundary property of % mbcmodel.testplan. The root of the boundary tree for two-stage test % plans contains boundary trees (mbcboundary.Tree objects) for local, % global and response boundary models in the Local, Global and Response % properties respectively. % % mbcboundary.TwoStageTree properties: % Local - local boundary model tree (read only) % Global - global boundary model tree (read only) % Response - response boundary model tree (read only) % BestModel - best boundary model for tree (read only) % InBest - boundary models selected as best % TestPlan - test plan object that contains this boundary tree (read only) % %See also Tree % Copyright 2009 The MathWorks, Inc. properties (SetAccess=private) %LOCAL local boundary model tree (read only) % Point-by-point and two-stage boundary models are fitted in the % local boundary model tree. These boundary models fit local % boundary models for each operating point and combine into a % single boundary model that includes the global inputs. % %See also PointByPoint, TwoStage Local %GLOBAL global boundary model tree (read only) % Boundary models in the global model boundary tree are fitted with % one point per test (the average value of the global variables for % that test). % % See also Model Global %RESPONSE response boundary model tree (read only) % Boundary models in the response model boundary tree are fitted with % all local and global input data for the test plan. % %See also Model Response end properties (Dependent,SetAccess=private) %BESTMODEL best boundary model (local, global and response) (read only) % BestModel is the boundary model combining the best local, global % and response boundary models. You can select which boundary % models to include in the best model with InBest. If more than one % boundary model is included in the best boundary model, the % boundary model is a mbcboundary.Boolean. % %See also InBest, Boolean BestModel end properties (Dependent) %INBEST logical array indicating which boundary models are selected as best % You can combine local, global and response boundary models into a % single boundary model for the test plan. The logical array % specifies whether to include the best local, global and response % boundary models, in that order, in the best boundary model for % the test plan. The best boundary model for the test plan is % given in BestModel. % %See also BestModel, Boolean InBest end properties(SetAccess=protected) %TESTPLAN test plan object that contains this boundary tree (read only) TestPlan end methods (Hidden) function BT = TwoStageTree(pRoot,TestPlan) %TwoStageTree - constructor not intended for public calls if nargin==0 pRoot = xregpointer; end BT@mbcutils.pointerinterface(pRoot); if nargin>1 BT.TestPlan = TestPlan; end end end methods function delete(T) % delete sub-tree if ~isempty(T.Local) && isvalid(T.Local) delete(T.Local) end if ~isempty(T.Global) && isvalid(T.Global) delete(T.Global) end if ~isempty(T.Response) && isvalid(T.Response) delete(T.Response) end end function B = get.Local(BT) if isempty(BT.Local) || ~isvalid(BT.Local) % tree has been deleted so make a new one B = iGetBoundaryTree(BT,1); % store object BT.Local = B; else B = BT.Local; end end function B = get.Global(BT) if isempty(BT.Global) || ~isvalid(BT.Global) % tree has been deleted so make a new one B = iGetBoundaryTree(BT,2); % store object BT.Global = B; else B = BT.Global; end end function B = get.Response(BT) if isempty(BT.Response) || ~isvalid(BT.Response) % tree has been deleted so make a new one B = iGetBoundaryTree(BT,0); % store object BT.Response = B; else B = BT.Response; end end function B = get.BestModel(BT) root = BT.Object; B = boundarymodel(root); end function S = get.InBest(T) root = T.Object; S = children(root,@isbest); S = logical([S{:}]); end function set.InBest(T,Best) root = T.Object; pChildren = children(root); if islogical(Best) && all(size(Best)==size(pChildren)) setbest(root,pChildren(Best) ); else error(message('mbc:boundarymodel:InvalidValue', length( pChildren ))) end end end methods (Access=protected) function B = iGetBoundaryTree(BT,level) if isvalid(BT.Pointer) pb = iGetBranch(BT,level); B= mbcboundary.Tree(pb,BT.TestPlan); else % pointer is no longer valid so return empty B = []; end end function pb = iGetBranch(BT,level) root = BT.Object; stages = children(root,@getstages ); index = find( [stages{:}] == level ); if isempty( index ) % make branch if needed pb = makechildren(root, false, 0 ); pb = address(pb); else pb = children(root,index); end end end end