Home > dal > stopcond_pdg.m

stopcond_pdg

PURPOSE ^

stopcond_pdg - "primal-dual" stopping condition

SYNOPSIS ^

function [ret, fval, spec, res]=stopcond_pdg(ww, uu, aa, tol, prob, A, B, lambda)

DESCRIPTION ^

 stopcond_pdg - "primal-dual" stopping condition

 Copyright(c) 2009 Ryota Tomioka
 This software is distributed under the MIT license. See license.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % stopcond_pdg - "primal-dual" stopping condition
0002 %
0003 % Copyright(c) 2009 Ryota Tomioka
0004 % This software is distributed under the MIT license. See license.txt
0005 
0006 function [ret, fval, spec, res]=stopcond_pdg(ww, uu, aa, tol, prob, A, B, lambda)
0007 
0008 fnc=prob.floss;
0009 %% Evaluate primal loss
0010 
0011 if ~isempty(uu)
0012   zz=A*ww+B*uu;
0013 else
0014   zz=A*ww;
0015 end
0016 
0017 [fl, gg] =feval(fnc.p, zz, fnc.args{:});
0018 spec=fevals(prob.fspec,ww);
0019 fval = fl+lambda*sum(spec);
0020 
0021 
0022 if isfield(prob,'Aeq')
0023   vv = [A', prob.Aeq']*aa;
0024   fval = fval+norm(prob.Aeq*ww-prob.ceq)^2/tol;
0025 else
0026   vv = A'*aa;
0027 end
0028 dnm = fevals(prob.dnorm, vv);
0029 
0030 if dnm>0
0031   aa    = min(1, lambda/dnm)*aa;
0032 end
0033 
0034 if ~isempty(uu)
0035   if isfield(prob,'Aeq')
0036     aa=aa(1:end-prob.meq);
0037   end
0038   aa=aa-B*((B'*B)\(B'*aa));
0039 end
0040 
0041 
0042 dloss = feval(fnc.d, aa, fnc.args{:});
0043 res   = fval-(-dloss);
0044 res   = res/fval;
0045 
0046 ret   = (res<tol);
0047 
0048 if res<0
0049   ret=0;
0050   res=inf;
0051 end
0052

Generated on Sat 22-Aug-2009 22:15:36 by m2html © 2003