LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
returnRT2.m
1function [ percentileRTs ] = returnRT2( arrival, service, pers, C, T_mode )
2
3% the RTs for K = 2
4
5service_h = build_Service_h(service);
6
7[ T, S, A_jump, S_Arr, sum_Ajump ] = computeT( arrival, service, service_h, C, T_mode);
8mWait = size(A_jump,1);
9phi = sum(T-S_Arr,2);
10[ pi0, En1 ] = computePi(T, arrival, service, service_h, C, S, A_jump);
11[ wait_alpha, wait_Smat, prob_wait, alfa ] = returnWait( En1, pi0, T, phi, sum_Ajump );
12
13% Waiting time percentiles
14percentileWait = returnPer(wait_alpha, wait_Smat, pers);
15
16%% Response time
17
18[ ST, dim, dim_notbusy ] = generateService(service, service_h, C, S);
19ST = kron(ST,arrival.Ia);
20
21% starting state of the service process
22pi0 = pi0/sum(pi0);
23dim = arrival.ma*dim;
24
25dim_notbusy = arrival.ma*dim_notbusy;
26% the starting state according to arrival a the not-all-busy period
27dim_service = dim + dim_notbusy; % except the empty state
28% the starting state of service for a job in a not-all-busy period
29notbusy_start = zeros(1,dim_service);
30notbusy_start(1:dim) = notbusy_start(1:dim)+(1-prob_wait)*pi0;
31% the starting state of service for a job in all-busy
32busy_start = zeros(1,dim_service);
33
34TS = T-S_Arr;
35busy_start(1:dim) = busy_start(1:dim)+prob_wait*alfa*TS/sum(alfa*TS);
36
37%% PH of response time
38Tr = size(ST,1);
39Sc = size(wait_Smat,2);
40TS_sum = sum(TS,2)*ones(1,arrival.ma*mWait);
41TS = TS./TS_sum;
42
43stat_service_phase = busy_start/(-ST);
44busy_nz = stat_service_phase>0;
45tr_start_state = -sum(ST,2)'*diag(stat_service_phase);
46tr_ST = zeros(size(ST));
47tr_ST(busy_nz,busy_nz) = diag(1./stat_service_phase(busy_nz))...
48 *ST(busy_nz,busy_nz)'*diag(stat_service_phase(busy_nz));
49
50tr_ST_exit = sum(-tr_ST,2);
51tr_ST_exit_mat = tr_ST_exit(1:Sc)*ones(1,Sc);
52
53
54TS2 = (TS')*diag(alfa);
55tr_TS_ind2 = sum(TS2,2);
56tr_TS_ind2(abs(tr_TS_ind2) < 10E-12) = ones(sum(abs(tr_TS_ind2) < 10E-12),1);
57tr_TS_ind2 = TS2./( tr_TS_ind2*ones(1,arrival.ma*mWait) );
58
59tildeP = [tr_ST_exit_mat.*tr_TS_ind2;zeros(Tr-Sc,Sc)];
60
61% removal of unreachable phases in tr_ST
62m_tr_ST = sum(busy_nz);
63tr_ST = tr_ST(busy_nz,busy_nz);
64tr_start_state = tr_start_state(busy_nz);
65tildeP = tildeP(busy_nz,:);
66
67gamma_res = [notbusy_start, tr_start_state zeros(1,Sc)];
68C_res = [ST, zeros(Tr,m_tr_ST), zeros(Tr,Sc);
69 zeros(m_tr_ST,Tr), full(tr_ST), tildeP;
70 zeros(Sc,Tr), zeros(Sc,m_tr_ST), wait_Smat];
71
72% Response time percentiles
73percentileRTs = returnPer( gamma_res, C_res, pers );
74