Commit 6fa73aac authored by Simon Maretzke's avatar Simon Maretzke
Browse files

more telling names for optimization parameters

parent e86181b0
......@@ -130,10 +130,13 @@ defaults.support = [];
defaults.minPhase = -inf;
defaults.maxPhase = inf;
defaults.useGPUIfPossible = true;
defaults.optimPar.maxIt = 100;
defaults.optimPar.tol = 1e-3;
defaults.optimPar.rho = 1e-2;
defaults.optimPar.verbose = false;
%
% Control parameters for the iterative optimization in the case of min-, max- or support-constraints:
% Only modify if you know what you are doing! (see private function fADMM for meaning of parameters)
defaults.optimization.maxIterations = 100; % maximum number of iterations
defaults.optimization.tolerance = 1e-3; % relative tolerance for determining convergence
defaults.optimization.rho = 1e-2; % stepsize parameter
defaults.optimization.verbose = false; % display status messages during optimization?
% Return default parameters if called without argument
if (nargin == 0)
......@@ -267,7 +270,7 @@ if numel(settings.support) || settings.minPhase > -inf || settings.maxPhase < i
% Compute minimizer using a fast ADMM algorithm
[result, stats] = fADMM(proxConstraints, proxCTF, ...
zeros(size(sumCTFHolograms), class(sumCTFHolograms)), ...
settings.optimPar);
settings.optimization);
% ----------------------------------------------------------------------------------------------- %
......
......@@ -120,9 +120,13 @@ function result = phaserec_nonlinTikhonov(holograms, fresnelNumbers, settings)
% Default parameters (widely identical to phaserec_ctf)
defaults = phaserec_ctf;
defaults.optimPar = struct;
defaults.optimPar.maxIt = 50;
defaults.optimPar.tol = 1e-2;
%
% Control parameters for the iterative optimization by projected gradient-descent:
% Only modify if you know what you are doing!
defaults.optimization = struct;
defaults.optimization.maxIterations = 50; % maximum number of iterations
defaults.optimization.tolerance = 1e-2; % relative tolerance for determining convergence
defaults.optimization.verbose = false; % display status messages during optimization?
% Return default parameters if called without argument
if (nargin == 0)
......@@ -191,7 +195,7 @@ N = size(holograms(:,:,1));
% ----------------------------------------------------------------------------------------------- %
settingsCTF = settings;
settingsCTF.optimPar = struct;
settingsCTF.optimization = struct;
settingsCTF.padx = 0; % Holograms are already padded,
settingsCTF.pady = 0; % so no more padding necessary
initialGuess = gpuArrayIf(phaserec_ctf(holograms, fresnelNumbers, settingsCTF), useGPU);
......@@ -267,9 +271,9 @@ end
% Perform reconstruction using projected gradient descent method with Barzilai-Borwein stepsizes
optimPar = settings.optimPar;
optimPar.projection = projection;
optimPar.initialStepsize = 1/(4*numHolos*(1+settings.betaDeltaRatio.^2) + max(settings.lim1, settings.lim2));
optimization = settings.optimization;
optimization.projection = projection;
optimization.initialStepsize = 1/(4*numHolos*(1+settings.betaDeltaRatio.^2) + max(settings.lim1, settings.lim2));
%
% Reference value for the norm of the gradient of TikhonovFunctional to measure convergence of
% the gradient descent setps. If betaDeltaRatio == 0, gradRef is exactly the gradient of
......@@ -283,16 +287,17 @@ if settings.betaDeltaRatio == 0
else
gradRef = F.adjoint(holograms - mean(mean(holograms,1),2));
end
optimPar.resiGradRef = gather(norm(gradRef(:)));
optimization.resiGradRef = gather(norm(gradRef(:)));
%
[result, stats] = projectedGradientDescent(TikhonovFunctional, initialGuess, optimPar);
[result, stats] = projectedGradientDescent(TikhonovFunctional, initialGuess, optimization);
% Print warning if convergence has not been achiveded to the prescribed tolerance
if ~stats.isConverged
warning(sprintf(['Optimization method has not converged to the required tolerance tol = %.2e ', ...
'within maxIt = %i iterations (final residual was %.2e > tol). ', ...
'Result may be inaccurate.'], optimPar.tol, optimPar.maxIt, stats.resiGradRel(end)));
warning(sprintf(['Optimization method has not converged to the required accuracy (tolerance = %.2e) ', ...
'within maxIterations = %i steps (final residual was %.2e > tolerance). ', ...
'Result may be inaccurate.'], ...
optimization.tolerance, optimization.maxIterations, stats.resiGradRel(end)));
end
......
......@@ -29,9 +29,9 @@ function [result, stats] = fADMM(proxH, proxG, v_hat_start, settings)
% Complete settings with default parameters
defaults.maxIt = 1e2;
defaults.maxIterations = 1e2;
defaults.eta = 0.999;
defaults.tol = 1e-3;
defaults.tolerance = 1e-3;
defaults.verbose = false;
if nargin < 4
......@@ -48,7 +48,7 @@ c_old = inf;
t = 1;
% Iterate
for jj = 1:settings.maxIt
for jj = 1:settings.maxIterations
% Optionally print status
if settings.verbose
......@@ -76,7 +76,7 @@ for jj = 1:settings.maxIt
end
% Check stopping conditions
if max(resi_primal, resi_dual) < settings.tol
if max(resi_primal, resi_dual) < settings.tolerance
break;
end
......
......@@ -28,8 +28,8 @@ defaults.initialStepsize = 1;
defaults.projection = [];
defaults.stepsizeRule = 'bbStepsize';
defaults.resiGradRef = [];
defaults.maxIt = 100;
defaults.tol = 1e-3;
defaults.maxIterations = 100;
defaults.tolerance = 1e-3;
defaults.linesearchDepth = 2;
defaults.linesearchStepsizeDecreaseFactor = 4;
defaults.linesearchMaxTries = 5;
......@@ -60,9 +60,9 @@ grad = F.getGradient();
%
% Prepare stats
stats = struct;
stats.functionalValues = nan([settings.maxIt,1]);
stats.resiGrad = nan([settings.maxIt,1]);
stats.resiGradRel = nan([settings.maxIt,1]);
stats.functionalValues = nan([settings.maxIterations,1]);
stats.resiGrad = nan([settings.maxIterations,1]);
stats.resiGradRel = nan([settings.maxIterations,1]);
stats.isConverged = false;
if isempty(settings.resiGradRef)
settings.resiGradRef = stats.resiGrad(jj);
......@@ -73,13 +73,13 @@ valuesLinesearch = -inf([settings.linesearchDepth,1]);
% Iterate
for it = 1:settings.maxIt
for it = 1:settings.maxIterations
% Save stats and check stopping conditions
stats.functionalValues(it) = value;
stats.resiGrad(it) = computeGradientResidual(grad, xhat, x, settings.projection, cache.stepsize);
stats.resiGradRel(it) = stats.resiGrad(it)/settings.resiGradRef;
if stats.resiGradRel(it) < settings.tol
if stats.resiGradRel(it) < settings.tolerance
stats.isConverged = true;
break;
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment