Permalink
Browse files

update submodule and calculate residual before iterating

  • Loading branch information...
LarsHaalck committed Oct 11, 2017
1 parent 0e76838 commit 6aa9c4a9ede1670a1e1f00cb14bcaa80766e16b5
Showing with 21 additions and 8 deletions.
  1. +20 −7 flexBox.m
  2. +1 −1 flexBox_CPP
@@ -20,8 +20,11 @@
xError %error estimates for primal parts
yError %error estimates for dual parts
error %combined error estimate
firstRun %internal flag specifying if algortihm has already been run
end
methods
function obj = flexBox
% Constructor
@@ -52,6 +55,8 @@
obj.xError = {};
obj.yError = {};
obj.firstRun = true;
end
function number = addPrimalVar(obj,dims)
@@ -149,7 +154,7 @@ function runAlgorithm(obj,varargin)
else
%initialize tau and sigma
obj.init();
obj.init();
end
%check if C++ module is activated and compiled
@@ -158,13 +163,20 @@ function runAlgorithm(obj,varargin)
else
reverseStr = [];
iteration = 1;error = Inf;
while error > obj.params.tol && iteration <= obj.params.maxIt
if obj.firstRun
obj.error = Inf;
obj.firstRun = false;
else
obj.error = obj.calculateError();
end
iteration = 1;
while obj.error > obj.params.tol && iteration <= obj.params.maxIt
obj.doIteration;
if (mod(iteration,obj.params.checkError) == 0)
error = obj.calculateError;
reverseStr = printToCmd( reverseStr,sprintf(['Iteration: #%d : Residual %.',num2str(-log10(obj.params.tol)),'f','\n'],iteration,error) );
obj.error = obj.calculateError();
reverseStr = printToCmd( reverseStr, sprintf(['Iteration: #%d : Residual %.', num2str(-log10(obj.params.tol)), 'f', '\n'], iteration, obj.error) );
end
if (obj.params.showPrimals > 0 && mod(iteration,obj.params.showPrimals) == 1)
@@ -194,6 +206,7 @@ function doCPP(obj)
obj.y{i} = resultCPP{numel(obj.x)+i};
end
obj.firstRun = false;
end
function doIteration(obj)
@@ -356,7 +369,7 @@ function init(obj)
%make sure the intended MEX file is called
addpath(absPathToMEX);
end
if (exist('flexBoxCPP','file') ~= 3)
CPPsupport = 0;
disp(['Warning: C++ module is not compiled!']);

0 comments on commit 6aa9c4a

Please sign in to comment.