www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/duplicatestores.m
function obj = duplicatestores(obj, Proj) %DUPLICATESTORES Perform duplication of variable stores for an optimization. % % OBJ = DUPLICATESTORES(OBJ, PROJ) is called when an optimization is % duplicated. This allows the optimization to change its unique ID and % duplicate the data it has stored in the variable dictionary. % Copyright 2005-2009 The MathWorks, Inc. % Generate a new unique object key OldID = obj.SetupGUID; obj.SetupGUID = guidarray(1); % Duplicate optimization data stores in the variable dictionary pDD = getdd(Proj); pDD.duplicatevariablestore(OldID, obj.SetupGUID); % Duplicate stores in variables that are not in the variable dictionary. % These variables are always internal to one of the objectives or % constraints for n = 1:length(obj.Objectives) i_changevarstore(obj.Objectives{n}, OldID, obj.SetupGUID); end for n = 1:length(obj.Constraints) i_changevarstore(obj.Constraints{n}, OldID, obj.SetupGUID); end function 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, @duplicatestore, OldID, NewID)); passign(pIntInputs, pveceval(pIntInputs, @removestore, OldID)); end end