34 lines
704 B
Matlab
34 lines
704 B
Matlab
function [A,MTTF,MTBF] = evaluate_CR(nm,n,lambdaB,lambdaR,muB,muR)
|
|
|
|
%% model definition
|
|
% notice: here last state is, by definition, one of the system failed states
|
|
[nstates,Qav,Qre,pi0] = CTMC_CR(nm,n,lambdaB,lambdaR,muB,muR);
|
|
|
|
%% solution of the availability model
|
|
tildeQ = Qav;
|
|
tildeQ(:,end) = ones(nstates,1);
|
|
|
|
elast = zeros(1,nstates);
|
|
elast(end) = 1;
|
|
|
|
% here only the last is a system failure state
|
|
|
|
% steady-state probability vector
|
|
pi = (tildeQ')\(elast');
|
|
|
|
% availability = MTTF/MTBF
|
|
A = sum(pi(1:end-1));
|
|
|
|
%% solution of the reliability model
|
|
hatQ = Qre(1:end-1,1:end-1);
|
|
|
|
hatpi0 = pi0(1:end-1);
|
|
|
|
tau = -(hatQ')\(hatpi0');
|
|
|
|
MTTF = (tau')*ones(nstates-1,1);
|
|
|
|
%% evaluate MTBF
|
|
MTBF = MTTF/A;
|
|
|
|
end |