% Input:
% C: nxd Matrix
% d: n-Vektor
% L: Matrix (containing the direction vectors row-wise)
% preferenceAlgo: String
% preferenceMethod: String
% bq: Vector

% Output:
% algorithm: String
% method: String
% results: Matrix

% Description:
% Checks if polyhedron C*x <= d can be represented with the prefered
% algorithm and method. If this is not the case the dialog to chose a way
% of handling the issue is opened. The output values are a working
% configuration in case there is one.

% Beschreibung:
% testet ob die angegebene Menge Cd mit dem gewünschten Algorithmus
% dargestellt werden kann und ruft falls nicht, den Dialog zur Auswahl
% einer anderen Alternative auf. Rückgabewerte sind funktionierende
% Einstellungen.

function [algorithm,method,results] = testSPalgos(C,d,L,preferenceAlgo,preferenceMethod,bq)
fprintf('  Test algorithms and methods for the construction of the next modes initial set ... \n');

continuetesting = true;

if ~isempty(preferenceAlgo) && ~isempty(preferenceMethod)
    nextX0 = calcPolytopeSP(C,d,preferenceAlgo,preferenceMethod,zeros(size(C,2),1),[],[]);
    
    continuetesting = ~performeSPTest(nextX0,L);
    algorithm = preferenceAlgo;
    method = preferenceMethod;
    results = d;
end;    

if continuetesting
    
    varargin = {C,d,L,preferenceAlgo,preferenceMethod,bq};
    output = mydialog2(varargin);
    algorithm = output{4};
    method = output{5};
    results = output{2};
    
    if output{1}
  
        fprintf('choice: %s with %s\n',method,algorithm);
        
    else
        error('Calculation terminated by user!\n');
    end;

end;

