www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/cgnbishadow.m
function [SHADOWX, SHADOWFVAL, EXITFLAG, OUTPUT,message] = cgnbishadow(FUN, X, NumberOfObjectives, A,B,Aeq,Beq,LB,UB,NONLCON, options, varargin) %CGNBISHADOW % Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. % Determine the shadow minima SHADOWFVAL that occurs at SHADOWX numberOfVariables = size(X,1); SHADOWX = zeros(numberOfVariables,NumberOfObjectives); SHADOWFVAL = zeros(NumberOfObjectives,1); EXITFLAG = zeros(1,NumberOfObjectives); message = cell(size(EXITFLAG)); OUTPUT.shadowIterations = 0; OUTPUT.shadowFuncCount = 0; for i = 1:NumberOfObjectives if any(EXITFLAG == -1) % User has terminated the optimization. Return NaNs for the other % objectives. SHADOWX(:, i) = NaN*ones(numberOfVariables, 1); SHADOWFVAL(i, 1) = NaN; OUTPUTi.shadowIterations = 0; OUTPUTi.shadowFuncCount = 0; message{i} = 'Solver stopped prematurely.'; else % determine shadow minima [SHADOWX(:,i),SHADOWFVAL(i,1), EXITFLAG(i), OUTPUTi] = ... fmincon(FUN,X,A,B,Aeq,Beq,LB,UB,NONLCON, options,i,varargin{:}); % update exitflag and output message{i} = OUTPUTi.message; end OUTPUT.shadowIterations = OUTPUT.shadowIterations + OUTPUTi.iterations; OUTPUT.shadowFuncCount = OUTPUT.shadowFuncCount+ OUTPUTi.funcCount; end if EXITFLAG > 0 F = zeros(NumberOfObjectives, NumberOfObjectives); for j = 1:size(SHADOWX,2) F(:,j) = feval(FUN, SHADOWX(:,j), 1:NumberOfObjectives, varargin{:}); end for i =1:NumberOfObjectives % find the smallest value of the objective [bestF,bestindex] = min(F(i,:)); if bestindex ~= i % We did not find the global minimum for one of the shadow problems % so recompute from improved starting point if ~strcmpi(options.Display, 'none') fprintf(['\nGlobal minimum not found for one of the shadow problems.', ... '\nRecomputing with alternative start position.\n\n']); end [thisX, thisFVAL, thisEXITFLAG, thisOUTPUT] = fmincon(FUN, ... SHADOWX(:,bestindex), A, B, Aeq, Beq, LB, UB, NONLCON, ... options, i, varargin{:}); if thisEXITFLAG > 0 && thisFVAL < SHADOWFVAL(i,1) SHADOWX(:,i) = thisX; SHADOWFVAL(i,1) = thisFVAL; OUTPUT.shadowIterations = OUTPUT.shadowIterations + ... thisOUTPUT.iterations; OUTPUT.shadowFuncCount = OUTPUT.shadowFuncCount + ... thisOUTPUT.funcCount; end end end end