www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/nextRun.m
function obj = nextRun(obj,nextIndex) %NEXTRUN Move object current run index to next in the list % % OBJ = NEXTRUN(OBJ) increments the optimization run so that the next one % is being done. % Copyright 2005-2015 The MathWorks, Inc. if nargin<2 nextIndex = obj.CurrentRun+1; end obj.Objectives = i_cleargradfcn(obj, obj.Objectives); obj.Constraints = i_cleargradfcn(obj, obj.Constraints); if nextIndex>0 && nextIndex<=length(obj.RunIndices) obj.CurrentRun = nextIndex; if obj.HasRunData % Reinitialize the gradient functions. This clears the persistent % gradient storage. obj.Objectives = i_resetgradfcn(obj, obj.Objectives); obj.Constraints = i_resetgradfcn(obj, obj.Constraints); end else % Do not set to run an impossible run obj.CurrentRun = 0; warning(message('mbc:cgoptimrunner:InvalidState6')); end function AllItemData = i_resetgradfcn(obj, AllItemData) AllSub = AllItemData.EvaluationData; SubNames = fieldnames(AllSub); for n = 1:length(SubNames) AllSub.(SubNames{n}).ExpressionGradFcn = pGradient(obj); end AllItemData.EvaluationData = AllSub; function AllItemData = i_cleargradfcn(obj, AllItemData) AllSub = AllItemData.EvaluationData; SubNames = fieldnames(AllSub); for n = 1:length(SubNames) AllSub.(SubNames{n}).ExpressionGradFcn = []; end AllItemData.EvaluationData = AllSub;