Skip to content

Commit

Permalink
Making compatible with R2015b due to "break" behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbeckr committed Dec 6, 2015
1 parent 0611bca commit fd817f2
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
19 changes: 15 additions & 4 deletions private/tfocs_backtrack.m
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
14 changes: 11 additions & 3 deletions private/tfocs_iterate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions tfocs_AT.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tfocs_GRA.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tfocs_LLM.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tfocs_N07.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tfocs_N83.m
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tfocs_TS.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit fd817f2

Please sign in to comment.