www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/replacekey.m

    function [OPT,newkey,pInt]= replacekey(OPT,pVars)
%REPLACEKEY replace GUID
% 
% newkey= replacekey(OPT,ProjB)

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

oldkey = OPT.SetupGUID;
newkey = guidarray(1);

% replace keys in all variables
passign(pVars, pveceval( pVars, @replacekey, oldkey, newkey) )


% replace stores in variables that are not in the variable dictionary.
% These variables are always internal to one of the objectives or
% constraints
pInt= mbcpointer(1,0);
for n = 1:length(OPT.Objectives)
    p= i_changevarstore(OPT.Objectives{n}, oldkey, newkey);
    pInt= [pInt p];
end
for n = 1:length(OPT.Constraints)
    p= i_changevarstore(OPT.Constraints{n}, oldkey, newkey);
    pInt= [pInt p];
end


% update key in 
OPT.SetupGUID= newkey;





function pInt= i_changevarstore(item, OldID, NewID)
pInt = getInternalPtrs(item);
if ~isempty(pInt)
    pInputs = getInputs(item);
    pIntInputs = intersect(pInputs, pInt);
    if ~isempty(pIntInputs)
        passign(pIntInputs, pveceval(pIntInputs, @replacekey, OldID, NewID));
    end
end