diff --git a/private/tfocs_backtrack.m b/private/tfocs_backtrack.m index eab6b48..1b766d2 100644 --- a/private/tfocs_backtrack.m +++ b/private/tfocs_backtrack.m @@ -1,13 +1,19 @@ % TFOCS_BACKTRACK % Backtracking helper script. +do_break = false; % added for compatibility with R2015b +while true + % Quick exit for no backtracking -if beta >= 1, break; end % SRB changing == to >= +if beta >= 1 + do_break = true; + break; +end % SRB changing == to >= % Quick exit if no progress made xy = x - y; xy_sq = tfocs_normsq( xy ); -if xy_sq == 0, localL = Inf; break; end +if xy_sq == 0, localL = Inf; do_break=true; break; end %fprintf('xy_sq/x is %.2e\n', xy_sq/tfocs_normsq(x) ); if xy_sq/tfocs_normsq(x) < eps, cntr_Ax=Inf; end % force a reset @@ -28,12 +34,17 @@ % Exit if Lipschitz criterion satisfied, or if we hit Lexact backtrack_steps = backtrack_steps + 1; -if localL <= L || L >= Lexact, break; end +if localL <= L || L >= Lexact, do_break=true; break; end if ~isinf( localL ), L = min( Lexact, localL ); -elseif isinf( localL ), localL = L; end +elseif isinf( localL ) + localL = L; +end L = min( Lexact, max( localL, L / beta ) ); +break; +end % end of "while true" + % TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant. % Copyright 2013 California Institute of Technology and CVX Research. % See the file LICENSE for full license information. diff --git a/private/tfocs_iterate.m b/private/tfocs_iterate.m index 799b236..380f54e 100644 --- a/private/tfocs_iterate.m +++ b/private/tfocs_iterate.m @@ -315,9 +315,15 @@ end % Exit if positive stopping criteria met -if ~isempty( status ), - break; -end +% if ~isempty( status ), +% break; +% end + +% for R2015b compatibility: +do_break = false; +if ~isempty( status ) + do_break = true; +else % Restart acceleration if necessary backtrack_steps = 0; @@ -353,6 +359,8 @@ C_y = Inf; +end + % TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant. % Copyright 2013 California Institute of Technology and CVX Research. % See the file LICENSE for full license information. diff --git a/tfocs_AT.m b/tfocs_AT.m index 0940bd3..44f1631 100644 --- a/tfocs_AT.m +++ b/tfocs_AT.m @@ -76,11 +76,13 @@ % Perform backtracking tests tfocs_backtrack + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end end diff --git a/tfocs_GRA.m b/tfocs_GRA.m index 1597fe5..ba44c4d 100644 --- a/tfocs_GRA.m +++ b/tfocs_GRA.m @@ -35,11 +35,13 @@ % Backtracking tfocs_backtrack + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end % new, for R2015b compatibility end diff --git a/tfocs_LLM.m b/tfocs_LLM.m index 939cf07..cf7172b 100644 --- a/tfocs_LLM.m +++ b/tfocs_LLM.m @@ -50,11 +50,13 @@ % Backtracking test tfocs_backtrack + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end % new, for R2015b compatibility % Scaled gradient. This step must be skipped if restart occurs if theta == 1 || isinf(theta) diff --git a/tfocs_N07.m b/tfocs_N07.m index 6f3e7e8..5811178 100644 --- a/tfocs_N07.m +++ b/tfocs_N07.m @@ -52,11 +52,12 @@ % Backtracking test tfocs_backtrack - + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end % new, for R2015b compatibility % Accumulated gradient. This step must be skipped if restart occurs if theta == 1 || isinf(theta) diff --git a/tfocs_N83.m b/tfocs_N83.m index 2c61825..15814c0 100644 --- a/tfocs_N83.m +++ b/tfocs_N83.m @@ -51,11 +51,13 @@ % Backtracking test tfocs_backtrack + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end % new, for R2015b compatibility % Reversed z update. This step is skipped if restart occurs if theta == 1, diff --git a/tfocs_TS.m b/tfocs_TS.m index 56734f7..e27ed9c 100644 --- a/tfocs_TS.m +++ b/tfocs_TS.m @@ -67,11 +67,13 @@ % Bactracking test tfocs_backtrack + if do_break, break; end % new, for R2015b compatibility end % Collect data, evaluate stopping criteria, and print status tfocs_iterate + if do_break, break; end % new, for R2015b compatibility g_a_old = g_a;