www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@contwostage/setActiveIndices.m

    function con = setActiveIndices(con, ai)
%SETACTIVEINDICES Set the indices of the active factors for a constraint
%
%  CON = SETACTIVEINDICES(CON, AI)
%
%  For two-stage constraints, all global factors must be active. 
%
%  Resetting the active factors resets the local constraint and global
%  model but preserves their classes.
%
%  See also CONTWOSTAGE, 
%           CONBASE/GETACTIVEINDICES,
%           CONBASE/GETACTIVEFACTORS,
%           CONBASE/NACTIVEFACTORSALLOWED,
%           CONBASE/SETMATCHEDFACTORS.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.

ngf = nfactors( con.Global{1} ); % number of global factors
preNlf = nFactors( con.Local ); % number of local factors before reset

% min and max number of local factors allowed
[minLf, maxLf] = nActiveFactorsAllowed( con.Local );

nai = length( ai ); % number of active indices

% The last ngf indices from ai will be the global factors. The other
% indices will be the local indices
postNlf = nai - ngf;
if minLf <= postNlf && postNlf <= maxLf,
    con.conbase = setActiveIndices( con.conbase, ai );
    cif = getInputFactors( con );
    con.Local = feval( class( con.Local ), cif(ai(1:postNlf)) );
    gm = makeXregmodel( cif(ai((postNlf+1:end))), class( con.Global{1} ) );
    [con.Global{:}] = deal( gm );
else
    error(message('mbc:contwostage:InvalidInput', upper( class( con.Local ) ), minLf, maxLf));
end

%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|