www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/+mbcboundary/TwoStage.m
classdef TwoStage < mbcboundary.AbstractBoundary %MBCBOUNDARY.TWOSTAGE two-stage boundary model class % Two-stage boundary models can only be created and fitted in the % local boundary tree in a two-stage test plan. Local boundary model % parameters are fitted using interpolating RBFs for global inputs. % Two-stage boundary models are valid at any operating point. % % mbcboundary.TwoStage properties: % Name - name of boundary model (read only) % NumberOfInputs - number of inputs (read only) % Type - boundary model type (read only) % Inputs - boundary model inputs % FitAlgorithm - fit algorithm for boundary model % Fitted - indicates whether boundary model has been fitted (read only) % LocalModel - local boundary model definition % GlobalModel - interpolating global model definition % % mbcboundary.TwoStage methods: % CreateBoundary - create a new boundary model % getAlternativeTypes - list of alternative boundary model types % Evaluate - evaluate boundary model % designconstraint - convert boundary model to a design constraint % getLocalBoundary - local boundary model for operating point % % Boundary models can be combined using the logical operators &, | and ~. % %See also Tree, TwoStageTree.Local, Model, getAlternativeTypes % Copyright 2009 The MathWorks, Inc. properties (Dependent) %LOCALMODEL local boundary model definition % LocalModel is the definition of the boundary model used to fit % each test. Two-stage boundary models only support Range and % Ellipsoid local boundary models. Local boundary model % parameters are fitted using interpolating RBFs for global inputs. % %See also Model, GlobalModel LocalModel %GLOBALMODEL interpolating global model definition % GlobalModel is an interpolating RBF model and is used to % interpolate the parameter values for local boundary models fitted % to each test. % %See also mbcmodel.CreateModel, LocalModel GlobalModel end methods (Hidden) function B = TwoStage(varargin) %TwoStage - constructor not intended for public calls B = B@mbcboundary.AbstractBoundary(varargin{:}); end end methods % get and set methods function L = get.LocalModel(B) con = getlocal(B.Object); opts = B.FitAlgorithm; if ~isempty(opts) opts = getObject(opts); end L = boundarymodel(con,opts,false); end function B = set.LocalModel(B,L) if isscalar(L) && isa(L,'mbcboundary.Model') && isequal(L.Inputs,B.LocalModel.Inputs) %scalar mbcdoe.boundarymodel with compatible inputs [localtypes,msg] = LocalConstraintTypes(B); if ~strcmp(L.Type,localtypes) % check that local boundary model is compatible error('mbc:mbcboundary:TwoStage:InvalidValue',... 'LocalModel.Type must be %s.',msg) end B.Object = setlocal(B.Object,dataobject(L)); B.pFitAlgorithm = L.FitAlgorithm; B = Reset(B); else error(message('mbc:mbcboundary:TwoStage:InvalidValue1')) end end function G = get.GlobalModel(B) gmods = getGlobalModels(B.Object); G = mbcmodel.CreateModel(gmods{1}); end function B = set.GlobalModel(B,G) if isscalar(G) && isa(G,'mbcmodel.model') && ... strcmp(G.Type,'Interpolating RBF') && isequal(G.Inputs,B.GlobalModel.Inputs) %Scalar Interpolating RBF mbcmodel.model with compatible inputs and B.Object = setglobal(B.Object,G.Object); B = Reset(B); else error(message('mbc:mbcboundary:TwoStage:InvalidValue2')) end end function L = getLocalBoundary(B,OpPoint) %GETLOCALBOUNDARY get local boundary model for operating point % L = getLocalBoundary(B,OpPoint); % A local boundary model is constructed by estimating the local % boundary parameters using GlobalModel and the supplied % operating point values, OpPoint. % %See also LocalModel, GlobalModel mbcboundary.AbstractBoundary.assertScalarFitted(B); G = getGlobalModels(B.Object); ng = nfactors(G{1}); if nargin<2 || ~isnumeric(OpPoint) || ~isequal(size(OpPoint),[1 ng]) error(message('mbc:mbcboundary:TwoStage:InvalidValue3', ng)) end beta = zeros(1,length(G)); for i=1:length(G) beta(:,i) = G{i}(OpPoint); end con = getlocal(B.Object,beta); L = boundarymodel(con,[],true); end end methods (Access=protected) function [opts,msg] = LocalConstraintTypes(B) if B.NumberOfInputs==1 opts = {'Range'}; msg = '''Range'''; else opts = {'Range','Ellipsoid'}; msg = '''Range'' or ''Ellipsoid'''; end end end end