1function [ pi0, En1 ] = computePi(T, arrival, services, service_h, C, S, A_jump)
3% computePi(T, arrival, service, C) returns the steady state distribution
4%
for the
case with 2 replicas (2 seperate queues)
7if services.SerChoice == 1
9 %% Construct the Se, Sestar matrices
11 [S_notallbusy] = constructNotAllBusy(C, services, service_h);
12 Q0 = kronsum(S_notallbusy,arrival.lambda0);
14 da = size(arrival.lambda0,1);
15 Igral = lyap(T,kron(eye(ms),arrival.lambda0),-eye(da*ms));
16 pi0mat = Igral*kron(A_jump,eye(da))*inv(Q0)*kron(eye(ms),arrival.lambda1);
18 % compute pi0 = pi0*pi0mat
19 pi0 = [zeros(1,ms*da),-1]/[(pi0mat - eye(ms*da)),sum(inv(T),2)];
21 En1 = 1/sum(pi0)*sum(pi0*pi0mat); % Igral*kron(A_jump,eye(da))*inv(Q0)*kron(eye(ms),arrival.lambda1))
25 [Se, Sestar, R0, Ke, Kc] = constructSRK(C, services, service_h, S);
26 dtmat = size(T,1)/size(arrival.lambda0,2);
29 Sedash = Se((dtmat+1):dsexp,(dtmat+1):dsexp);
30 Rbusy = R0((dtmat+1):dsexp,:);
32 Iidle = Iidle(:,(dtmat+1):dsexp);
33 da = length(arrival.lambda0);
34 Iidle = kron(Iidle,eye(da));
36 Q0 = kronsum(Sedash,arrival.lambda0); % state changes between arrivals
37 Qbusy = kron(Rbusy,arrival.lambda1); %
return to all-busy state
39 Bmap = -(Iidle/Qidle)*Qbusy;
40 Kemap = kron(Ke,eye(da));
41 Kcmap = kron(Kc,eye(da));
43 BB = kron(eye(size(Sestar,2)),arrival.lambda0);
44 Igral = lyap(T,BB,Kemap*kron(Sestar,eye(da))); % solves the Sylvester equation AX+XB+C=0
45 pi0mat = Igral*Bmap*Kcmap; % equation (7.2)
47 % compute pi0 = pi0*pi0mat
48 pi0 = [zeros(1,dtmat*da),-1]/[(pi0mat - eye(dtmat*da)),sum(inv(T),2)];
50 En1 = 1/sum(pi0)*sum(-pi0*Igral*Iidle/Qidle*kron(eye(size(Sedash,2)),arrival.lambda1)); % E(n1)