function [solver,RT] = checkSolver(solver,RT,myCQN)
% CHECKSOLVER checks whether the selected solver is adequate given the 
% required output (response time distribution) and the characteristics
% of the queueing network model to analyze. It also assigns the automatic 
% solver. 
%
% Parameters:
% solver:   solver originally selected
% RT:       1 if response-time distributions are to be computed, 0
%           otherwise
% myCQN:    CQN model to analyze
% 
% Copyright (c) 2012-2015, Imperial College London 
% All rights reserved.


%% define solver
if solver == 0 % 'AUTO'
    solver = 1; % set default solver to fluid
elseif solver == 2 % 'QD-AMVA'
    if RT > 0 % response time distribution requested
        fprintf(['\nWarning: Response time distribution requested with solver QD-AMVA. \n', ...
                 'Solver QD-AMVA cannot compute response time distributions. \n', ...
                 'Response time distributions wont be computed. \n', ...
                 'To compute response time distributions please select AUTO or FLUID solvers. \n']);
        RT = 0;
    end

    if myCQN.C ~= myCQN.K % class switching present
        fprintf(['\nWarning: The queueing network features class-switching with solver QD-AMVA. \n', ...
                 'Solver QD-AMVA cannot consider queueing networks with class-switching. \n', ...
                 'Solver will be modified to FLUID (1) to consider the class-switching behavior. \n']);
        solver = 1;
    end

elseif solver ~= 1
    fprintf(['\nWarning: Solver option ', solver, ' not recognized. \n', ...
             'Using default solver: FLUID (1). \n' ]);
    solver = 1;
end