www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgexpr/evaluateOverDesign.m
function out = evaluateOverDesign(obj, varargin) %EVALUATEOVERDESIGN Evaluate expression over a space filling design % % OUT = EVALUATEOVERDESIGN(OBJ) returns an evaluation of OBJ over a space % filled set of input points. This evaluation is useful in determining % an approximate range of the expression. % % OUT = EVALUATEOVERDESIGN(OBJ, QUANTITY) returns an evaluation of OBJ % over a space filled design for the specified quantity. QUANTITY must be % a function handle to an expression method of the form Y = FUNC(OBJ). % Copyright 2005-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. pInp = cgindependentvars(getinports(obj)); nf = length(pInp); if nf>0 R = pveceval(pInp, @getrange); % Use a halton set to spread evaluations around the space cs1 = cset_haltonset({R, 1000}); cs1 = set(cs1, 'Scramble', 'RR2'); cs1 = set(cs1, 'PrimeLeap', true); cs1 = set(cs1, 'SkipZero', true); if nf>8 % Use a Plackett-Burman design to get scattered coverage of % corners. The number of runs is chosen so that we never create a % design that is the absolute minimum number of runs for the number % of factors. NumPBRuns = max(9, ceil(0.5+log2(nf))); cs2 = cset_pb({R, 2^NumPBRuns}); else % Use a full factorial to hit all corners cs2 = cset_grid(R); end X = num2cell([fullset(cs1); fullset(cs2)],1); passign(pInp, parrayeval(pInp, @setvalue, {X})); if isSwitchExpr(obj) % Snap the inports to switch points for the switch variables - this % changes the values that are currently in the inports. % This will only work well on fairly simple switching model setups. getClosestSwitchPoint(obj); end out = evaluate(obj, varargin{:}); else % This is a source item. If it is an inport item then we can use the % range to generate typical values, otherwise just use the source's % value if isinport(obj) R = getrange(obj); obj = setvalue(obj, linspace(R(1), R(2), 1000)); out = evaluate(obj, varargin{:}); else out = evaluate(obj, varargin{:}); end end