# autoparam3alpha

Analogous to autoparam3 but looking for the best regularization parameter alpha if beta = 0. See autoparam3.html for documentation.

Warning: This function clears variables, creates a directory and creates files.

## Contents

- Code

## Code

    disp(' ')
    disp('----- Automatic choice of regularization parameter alpha (for beta = 0) -----')
    disp(' ')

    close all;
    if ~exist('inseti','var')
        inseti = '';
    end
    clearvars -except inseti;
    ticAutoParam = tic;

In-place settings:

    % ----------------------------------------------------------------------
    % Set initial regularization parameter alpha:

    switch inseti
        case 'example3Dalg'
            alpha0 = 1000;
        case 'fresnelPda'
            alpha0 = 1E6;
        case 'shipBorePda'
            alpha0 = 1000;
        case 'shipBorePdaNlast'
            alpha0 = 1000;
        case 'fresnelShrink'
            alpha0 = 1E3;
        case 'fresnelSynthShrink'
            alpha0 = 0.01;
        case 'shipBorePdaWav'
            alpha0 = 0.01;
        case 'shipBoreShrinkWav'
            alpha0 = 1E-2;
        case 'shipFactMeth'
            alpha0 = 1E4;
        case 'defaultFactMeth'
            alpha0 = 1E6;
        otherwise
            alpha0 = 1E5;
    end

    % ----------------------------------------------------------------------

    % Further in-place settings (changes are not recommended):
    %
    N = 30; % maximal number of steps in bisection method
    q = 500/1E-5; % quotient of alpha/beta (default: seti.alpha = 500; seti.beta = 1E-5;)

    dummy = 0; % 0: no dummy function (use IPscatt); 1: dummy function to test this routine (result \approx 500)

Initialization

    inAuto01init;
    alpha(1) = alpha0;

Process

    for i = 1:N
        % Evaluate the current alpha

        % beta(i) = 0; % beta = alpha./q; % compute beta
        inAuto02eval; % Reconstruction with alpha and beta; check, whether discrepancy principle border reached; output result

        inAuto03decAlpha; % decision (try alpha/beta and decide which alpha is next tried)
        if breakfor % breakfor is set in inAuto03decAlpha;
            break;
        end
    end

Output

    if startbis == 0
        disp('Attention: startbis is still 0, i.e. the choice was stopped although bisection method was not started yet.')
        disp('Suggestions:');
        disp('  - Increase the number of iterations N to search a parameter.')
        disp('  - Increase seti.tau to reach the discrepancy principle.')
        disp('  - Increase the numer of iterations of the inversion to get a better result.')
    end

    if startbis == 1
        disp('Choose last a as alpha, because it fulfills the discrepancy principle.')
        disp('Result of automatic parameter choice:')
        % fprintf('alpha = %g, beta = %g\n',alpha(i),beta(i));
        % fprintf('results in dis = %g\n',disAlphaBeta(i)');

        fprintf('alpha = %g, beta = 0\n',a); % is adapted for autoparam3alpha;
        fprintf('results in dis = %g\n',da);
    end
    tocAutoParam = toc(ticAutoParam);
    fprintf('Elapsed time of automatic parameter choice is %05.1f min.\n',tocAutoParam/60);

    % -- Plot results --
    regplot = alpha(1:stopind); % regplot is alpha(...) or beta(...)
    inAuto04plot; % plot

    usevaralphabeta = 0; % take it out of service for further computations