LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MAPMSGCompiler.m
1% O. Gursoy, K. A. Mehr, N. Akar:
2% The MAP/M/s + G Call Center Model with Generally Distributed Patience Times: Steady-state Solution and First Passage Time Distribution
3% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4% Steady-state and first passage time solver for MAP/M/s + G queues
5%
6% INPUTS
7%-----------------------------
8% -SOLUTION: Solution type(steady state or first passage actual/virtual)
9% -SERVERSIZE: server size of the call center problem
10% -mu
11% -C: C of MAP(C,D)
12% -D: D of MAP(C,D)
13% -MAPSIZE: Order of MAP(C,D) distribution, Service Rate(mu)
14% -QUANTIZATION: number of regimes that will quantize abandonment function ga
15% -BoundaryLevels: Boundary levels of Regimes
16% -ga: Abandonment Probability in Each Regime (starts with a 0 value)
17% -gabanfunction: for continious abandonment functions enter ccdf of abandonement as a function of x
18%
19%
20% INPUTS for first passage times(these are not necessary for steady state
21% calculations)
22%-----------------------------
23% -b: threshold level
24% -tau: time horizon
25% -CMEorErlang: indicator of which distribution is chosen for approximation
26% -OrderofPHCME: order of the chosen approximator (25, 51 or 101)
27% -pi0: initial server occupancy distribution
28% -theta0: initial MAP state distribution
29%
30% OUTPUTS
31%---------------------------
32% -steadyStateResult: 1x7 steady state result vector including PR{W=0}
33% PR{W=0|S} PR{A} E{W|S} Var{W|S} Fw|s,w>0(.1) Fw|s,w>0(.2)
34% respectively(when SOLUTION=1).
35%
36% -FirstPassageTimeofVirtual: First passage time probability for the virtual waiting time(when SOLUTION=2).
37%
38% -FirstPassageTimeofActual: First passage time probability for the actual
39% waiting time(when SOLUTION=3).
40%
41%
42% IMPORTANT:
43%-----------
44% For first passage time cases the initial wait time, a=0.
45%
46%
47%_________________________________________________________________
48%
49
50clc;
51close all;
52clear all;
53
54tol=10^-5;
55
56%INPUTS___________________________________________________________
57%
58
59%solution=1 if steady state, solution=2 if first passage distribution of virtual waiting time,
60%solution=3 if first passage distribution of actual waiting time,
61SOLUTION=3;
62
63%server size, state size of MAP(C,D), service rate and QUANTIZATION (regime count)
64SERVERSIZE=10;
65MAPSIZE=2;
66mu=1;
67QUANTIZATION=11;
68
69% C,D matrices (2 state MAP(C,D) is default)
70%-------------------------------------------
71decay=0.95;
72 rho=0.99;
73 S=SERVERSIZE;
74 m=MAPSIZE;
75 C_onsquared = 16;
76 mean_arrival = 1/(S*mu*rho);
77 e = ones(m,1);
78
79 p_1 = 0.5*(1 + sqrt((C_onsquared-1)/(C_onsquared+1)));
80 p_2 = 1-p_1;
81 mu_1 = 2*p_1 / mean_arrival;
82 mu_2 = 2*p_2 / mean_arrival;
83
84 v = [p_1 p_2];
85 T = [-mu_1 0;0 -mu_2];
86 T1 = T;
87 T0 = [mu_1; mu_2];
88 s = T0;
89 lambda = 1/mean_arrival;
90 D0 = T1;
91 D1 = (1-decay)*T0*v - decay*T1 ;
92C=D0;
93D=D1;
94em=ones(MAPSIZE,1);
95lmap=D*em;
96
97
98
99%abandonment prob for regimes (ga) and boundary levels (BoundaryLevels)
100%---------------------------------------------------------------------
101%(piecewise constant abandonment function is default)
102BoundaryLevels = linspace(0,10,QUANTIZATION);
103ga=0.10*floor(BoundaryLevels);
104BoundaryLevels(1)=[];
105BoundaryLevels(end+1)=10000000;
106ga=[0 ga];
107
108
109%Uncomment for continious abandonment function**
110% interval=1/(QUANTIZATION);
111% ga(1)=0;
112% for k=1:QUANTIZATION
113% ga(k+1)=interval*k+ga(1);
114% end
115% regime=1;
116% for i=1:100000000
117% x=i/1000000;
118% %enter ccdf of abandonement as a function of x**
119% gabanfunction=1-exp(-x)-x*exp(-x)-x^2*exp(-x)/2;
120% if (ga(regime+1)+tol>gabanfunction)&&(ga(regime+1)-tol<gabanfunction)
121% BoundaryLevels(regime)=x;
122% if regime<QUANTIZATION
123% regime=regime+1;
124% end
125% end
126% end
127% gatemp=ga;
128% for i=2: length(ga)
129% gatemp(i)=(ga(i-1)+ga(i))/2;
130% end
131% ga=gatemp;
132
133
134
135%if first passage distribution is chosen (SOLUTION=3) enter the parameters**
136%------------------------------------------------------------
137b=0.25;
138tau=1;
139%initial server occupancy distribution
140pi0=[1 0 0 0 0 0 0 0 0 0 0];
141%initial MAP state distribution
142theta0=[0 1];
143%CMEorErlang=1 for CME approximation and CMEorErlang=0 for Erlangization
144CMEorErlang=0;
145%order of PH or CME, order=25 if OrderofPHCME=1, order=51 if OrderofPHCME=2, order=101 if OrderofPHCME=3,
146OrderofPHCME=1;
147
148%END OF INPUTS _______________________________________________________
149%
150
151
152%CALCULATIONS_____________________________________________________
153%
154
155%construction of infinitesial generators and drift matrices for both regimes (Qy,ydriftregimes)and
156%boundaries (Qybounds,ydriftbounds)
157I=eye(MAPSIZE);
158Qy0=zeros((SERVERSIZE+1)*size(I,1),(SERVERSIZE+1)*size(I,1));
159Qy=zeros((SERVERSIZE+1)*size(I,1),(SERVERSIZE+1)*size(I,1),QUANTIZATION);
160Rydiag=-ones(1,size(Qy0,1));
161Rydiag(size(Qy0,1)-size(I,1)+1:size(Qy0,1))=-Rydiag(size(Qy0,1)-size(I,1)+1:size(Qy0,1));
162Ry=diag(Rydiag);
163for row=1:SERVERSIZE+1
164 if row ==1
165 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE)=C;
166 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row)*MAPSIZE+1: (row)*MAPSIZE+MAPSIZE)=D;
167 elseif row==SERVERSIZE+1
168 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE)=-(row-1)*mu*I;
169 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-2)*MAPSIZE+1: (row-2)*MAPSIZE+MAPSIZE)=(row-1)*mu*I;
170 else
171 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE)=C-(row-1)*mu*I;
172 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-2)*MAPSIZE+1: (row-2)*MAPSIZE+MAPSIZE)=(row-1)*mu*I;
173 Qy0((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row)*MAPSIZE+1: (row)*MAPSIZE+MAPSIZE)=D;
174 end
175end
176
177for regimecount=1:QUANTIZATION
178 for row=SERVERSIZE:SERVERSIZE+1
179 if row ==SERVERSIZE
180 Qy((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE,regimecount)=(ga(regimecount+1))*D+C;
181 Qy((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row)*MAPSIZE+1: (row)*MAPSIZE+MAPSIZE,regimecount)=(1-(ga(regimecount+1)))*D;
182 elseif row==SERVERSIZE+1
183 Qy((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE,regimecount)=-(row-1)*mu*I;
184 Qy((row-1)*MAPSIZE+1: (row-1)*MAPSIZE+MAPSIZE, (row-2)*MAPSIZE+1: (row-2)*MAPSIZE+MAPSIZE,regimecount)=(row-1)*mu*I;
185 end
186 end
187 ydriftregimes(regimecount,:)=Rydiag;
188 Ryregimes(:,:,regimecount)=Ry;
189end
190Qybounds=cat(3,Qy0,Qy);
191ydriftbounds=cat(1,Rydiag,ydriftregimes);
192Rybounds=cat(3,Ry,Ryregimes);
193
194if OrderofPHCME==1
195 OrderofPH=25;
196elseif OrderofPHCME==2
197 OrderofPH=51;
198elseif OrderofPHCME==3
199 OrderofPH=101;
200end
201
202%Based on the chosen SOLUTION make adjustments for the input of MRMFQ solver
203if SOLUTION==1
204 driftbound=ydriftbounds;
205 driftregimes=ydriftregimes;
206 Qregimes=Qy;
207 Qbounds=Qybounds;
208 BoundaryLevelsLast=BoundaryLevels;
209elseif SOLUTION==2
210 if CMEorErlang==1
211 n=OrderofPH;
212 [MESystem,cv]= CMEParameterCalculator(n,tau);
213 S=MESystem.A;
214 S0=MESystem.b;
215 alpha=MESystem.c;
216 else
217 alpha=zeros(1,OrderofPH);
218 alpha(1)=1;
219 ss=-ones(1,OrderofPH);
220 S=diag(ss);
221 for y=1:OrderofPH-1
222 S(y,y+1)=1;
223 end
224 S=OrderofPH*S/tau;
225 e=ones(length(S),1);
226 S0=-S*e;
227 end
228 count=1;
229 while BoundaryLevels(count)<b
230 count=count+1;
231 end
232 BoundaryLevelsLast=BoundaryLevels(1:count);
233 BoundaryLevelsLast(count)=b;
234
235 for reg=1:length(BoundaryLevelsLast)
236 eTilde= ones(1,length(Qybounds(:,:,reg+1)));
237 eTilde(end-MAPSIZE+1:end)=0;
238 Itilde=diag(eTilde);
239
240 Qz(:,:,reg)=[0 zeros(1,length(kron(alpha,kron(pi0,theta0))));kron(S0,diag(Itilde)) (kron(eye(length(S)),Qy(:,:,reg))+kron(S,Itilde))];
241 Qzbounds(:,:,reg+1)=[0 zeros(1,length(kron(alpha,kron(pi0,theta0))));kron(S0,diag(Itilde)) (kron(eye(length(S)),Qybounds(:,:,reg+1))+kron(S,Itilde))];
242
243 Rz(:,:,reg)=diag([-1 ones(1,size(kron(eye(length(S)),Ryregimes(:,:,reg)),1))* kron(eye(length(S)),Ryregimes(:,:,reg))]);
244 Rzbounds(:,:,reg+1)=diag([-1 ones(1,size(kron(eye(length(S)),Rybounds(:,:,reg+1)),1))* kron(eye(length(S)),Rybounds(:,:,reg+1))]);
245 end
246 Qzbounds(:,:,1)=[-1 kron(alpha,kron(pi0,theta0));kron(S0,diag(Itilde)) (kron(eye(length(S)),Qybounds(:,:,1))+kron(S,Itilde))];
247 Rzbounds(:,:,1)=diag([-1 ones(1,size(kron(eye(length(S)),Rybounds(:,:,1)),1))* kron(eye(length(S)),Rybounds(:,:,1))]);
248 Qzbounds(:,:,end)=[0 zeros(1,length(kron(alpha,kron(pi0,theta0)))); ones(size(Qzbounds(:,:,1),1)-1,1) -eye(size(Qzbounds(:,:,1),1)-1)];
249 Rzbounds(:,:,end)=Rzbounds(:,:,1).*0;
250 Rzbounds(1,1,end)=-1;
251
252 Qregimes=Qz;
253 Qbounds=Qzbounds;
254 driftbound(1,:)=[diag(Rzbounds(:,:,1))'];
255
256 for reg=1:length(BoundaryLevelsLast)
257 driftregimes(reg,:)=[diag(Rz(:,:,reg))'];
258 driftbound(reg+1,:)=[diag(Rzbounds(:,:,reg+1))'];
259 end
260
261elseif SOLUTION==3
262 if CMEorErlang==1
263 n=OrderofPH;
264 [MESystem,cv]= CMEParameterCalculator(n,tau);
265 S=MESystem.A;
266 S0=MESystem.b;
267 alpha=MESystem.c;
268 else
269 alpha=zeros(1,OrderofPH);
270 alpha(1)=1;
271 ss=-ones(1,OrderofPH);
272 S=diag(ss);
273 for y=1:OrderofPH-1
274 S(y,y+1)=1;
275 end
276 S=OrderofPH*S/tau;
277 e=ones(length(S),1);
278 S0=-S*e;
279 end
280 count=1;
281 while BoundaryLevels(count)<b
282 count=count+1;
283 end
284 BoundaryLevelsLast=BoundaryLevels(1:count);
285 BoundaryLevelsLast(count)=b;
286 BoundaryLevelsLast(count+1: length(BoundaryLevels)+1)=BoundaryLevels(count: length(BoundaryLevels));
287 Rytemp=Ryregimes;
288 Ryboundstemp=Rybounds;
289 Qytemp=Qy;
290 Qyboundstemp=Qybounds;
291 Rytemp(:,:,end+1)=Ry;
292 Ryboundstemp(:,:,end+1)=Ry;
293 Qytemp(:,:,count+1:end+1)=Qy(:,:,count:end);
294 Qyboundstemp(:,:,count+2:end+1)=Qybounds(:,:,count+1:end);
295 Qyboundstemp(:,:,count+1)=Qybounds(:,:,count+1);
296
297 for reg=1:length(BoundaryLevelsLast)
298 eTilde= ones(1,length(Qybounds(:,:,reg)));
299 eTilde(end-MAPSIZE+1:end)=0;
300 ITilde=diag(eTilde);
301
302 QzTilde(:,:,reg)=[0 0 zeros(1,length(kron(alpha,kron(pi0,theta0))));0 0 zeros(1,length(kron(alpha,kron(pi0,theta0))));zeros(length(kron(S0,diag(ITilde))),1) kron(S0,diag(ITilde)) (kron(eye(length(S)),Qytemp(:,:,reg))+kron(S,ITilde))];
303 QzboundsTilde(:,:,reg+1)=[0 0 zeros(1,length(kron(alpha,kron(pi0,theta0))));0 0 zeros(1,length(kron(alpha,kron(pi0,theta0))));zeros(length(kron(S0,diag(ITilde))),1) kron(S0,diag(ITilde)) (kron(eye(length(S)),Qyboundstemp(:,:,reg+1))+kron(S,ITilde))];
304
305 RzTilde(:,:,reg)=diag([-1 -1 ones(1,size(kron(eye(length(S)),Rytemp(:,:,reg)),1))* kron(eye(length(S)),Rytemp(:,:,reg))]);
306 RzboundsTilde(:,:,reg+1)=diag([-1 -1 ones(1,size(kron(eye(length(S)),Ryboundstemp(:,:,reg+1)),1))* kron(eye(length(S)),Ryboundstemp(:,:,reg+1))]);
307 end
308 QzboundsTilde(:,:,1)=[-1 1 zeros(1,length(kron(alpha,kron(pi0,theta0))));0 -1 kron(alpha,kron(pi0,theta0));zeros(length(kron(S0,diag(ITilde))),1) kron(S0,diag(ITilde)) (kron(eye(length(S)),Qybounds(:,:,1))+kron(S,ITilde))];
309 RzboundsTilde(:,:,1)=diag([-1 -1 ones(1,size(kron(eye(length(S)),Ryboundstemp(:,:,1)),1))* kron(eye(length(S)),Ryboundstemp(:,:,1))]);
310
311 Qregimes=QzTilde;
312 Qbounds=QzboundsTilde;
313
314 driftbound(1,:)=[diag(RzboundsTilde(:,:,1))'];
315
316 for reg=1:length(BoundaryLevelsLast)
317 driftregimes(reg,:)=[diag(RzTilde(:,:,reg))'];
318 driftbound(reg+1,:)=[diag(RzboundsTilde(:,:,reg+1))'];
319 end
320 for reg=count+1:length(BoundaryLevelsLast)
321 for d=1:OrderofPH
322 index=2+(d-1)*size(Qy,2)+size(Qy,2)-2*MAPSIZE+1;
323 Qbounds(index:index+MAPSIZE-1,1,reg)=Qbounds(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,reg)*ones(MAPSIZE,1);
324 Qbounds(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,reg)=zeros(MAPSIZE,MAPSIZE);
325 Qregimes(index:index+MAPSIZE-1,1,reg)=Qregimes(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,reg)*ones(MAPSIZE,1);
326 Qregimes(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,reg)=zeros(MAPSIZE,MAPSIZE);
327 end
328 end
329 Qbounds(index:index+MAPSIZE-1,1,end)=Qbounds(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,end)*ones(MAPSIZE,1);
330 Qbounds(index:index+MAPSIZE-1,index+MAPSIZE:index+2*MAPSIZE-1,end)=zeros(MAPSIZE,MAPSIZE);
331
332end
333
334
335%MRMFQ solver
336[coefficients,boundaries,Lzeromulti,Lnegmulti,Lposmulti,Anegmulti,Aposmulti]=MRMFQSolver(Qregimes,Qbounds,driftregimes,driftbound,BoundaryLevelsLast);
337Qregimes=[];
338Qbounds=[];
339driftregimes =[];
340driftbound=[];
341QzTilde=[];
342RzTilde=[];
343QzboundsTilde=[];
344RzboundsTilde=[];
345Qz=[];
346Rz=[];
347Qzbounds=[];
348Rzbounds=[];
349B=BoundaryLevelsLast;
350
351%OUTPUT CALCULATION_______________________________________________________
352%
353%Based on the chosen SOLUTION get the results from the outputs of MRMFQ solver
354if SOLUTION==1
355 zeromass=boundaries{1};
356 integral(1,:) =coefficients{1}*[Lzeromulti{1}*(B(1)-0); Anegmulti{1}\‍(expm(Anegmulti{1}*((B(1)-0)))-eye(size(Anegmulti{1},1)))*Lnegmulti{1};(Aposmulti{1})\(eye(size(Aposmulti{1},1))-expm((-Aposmulti{1})*(B(1)-0)))*Lposmulti{1}];
357 waitintegral(1,:) =(B(1)/2)*(1-(ga(2)))*coefficients{1}*[Lzeromulti{1}*(B(1)-0); Anegmulti{1}\‍(expm(Anegmulti{1}*((B(1)-0)))-eye(size(Anegmulti{1},1)))*Lnegmulti{1};(Aposmulti{1})\(eye(size(Aposmulti{1},1))-expm((-Aposmulti{1})*(B(1)-0)))*Lposmulti{1}];
358 abandonintegral(1,:) =(ga(2))*coefficients{1}*[Lzeromulti{1}*(B(1)-0); Anegmulti{1}\‍(expm(Anegmulti{1}*((B(1)-0)))-eye(size(Anegmulti{1},1)))*Lnegmulti{1};(Aposmulti{1})\(eye(size(Aposmulti{1},1))-expm((-Aposmulti{1})*(B(1)-0)))*Lposmulti{1}];
359 successfulintegral(1,:) =(1-(ga(2)))*coefficients{1}*[Lzeromulti{1}*(B(1)-0); Anegmulti{1}\‍(expm(Anegmulti{1}*((B(1)-0)))-eye(size(Anegmulti{1},1)))*Lnegmulti{1};(Aposmulti{1})\(eye(size(Aposmulti{1},1))-expm((-Aposmulti{1})*(B(1)-0)))*Lposmulti{1}];
360 for d=2:QUANTIZATION
361 integral(d,:) =coefficients{d}*[Lzeromulti{d}*(B(d)-B(d-1)); Anegmulti{d}\‍(expm(Anegmulti{d}*((B(d)-B(d-1))))-eye(size(Anegmulti{d},1)))*Lnegmulti{d};(Aposmulti{d})\(eye(size(Aposmulti{d},1))-expm((-Aposmulti{d})*(B(d)-B(d-1))))*Lposmulti{d}];
362 waitintegral(d,:) =((B(d)+B(d-1))/2)*(1-(ga(d+1)))*coefficients{d}*[Lzeromulti{d}*(B(d)-B(d-1)); Anegmulti{d}\‍(expm(Anegmulti{d}*((B(d)-B(d-1))))-eye(size(Anegmulti{d},1)))*Lnegmulti{d};(Aposmulti{d})\(eye(size(Aposmulti{d},1))-expm((-Aposmulti{d})*(B(d)-B(d-1))))*Lposmulti{d}];
363 abandonintegral(d,:) =(ga(d+1))*coefficients{d}*[Lzeromulti{d}*(B(d)-B(d-1)); Anegmulti{d}\‍(expm(Anegmulti{d}*((B(d)-B(d-1))))-eye(size(Anegmulti{d},1)))*Lnegmulti{d};(Aposmulti{d})\(eye(size(Aposmulti{d},1))-expm((-Aposmulti{d})*(B(d)-B(d-1))))*Lposmulti{d}];
364 successfulintegral(d,:) =(1-(ga(d+1)))*coefficients{d}*[Lzeromulti{d}*(B(d)-B(d-1)); Anegmulti{d}\‍(expm(Anegmulti{d}*((B(d)-B(d-1))))-eye(size(Anegmulti{d},1)))*Lnegmulti{d};(Aposmulti{d})\(eye(size(Aposmulti{d},1))-expm((-Aposmulti{d})*(B(d)-B(d-1))))*Lposmulti{d}];
365 end
366
367 x=[0.1 0.2];
368 ArrivalsWaitLessThanX=zeros(length(x),size(integral,2));
369 for d=1:length(x)
370 count=1;
371 while B(count)<x(d)
372 count=count+1;
373 end
374 if count>1
375 int=(1-(ga(count+1)))*coefficients{count}*[Lzeromulti{count}*(x(d)-B(count-1)); Anegmulti{count}\‍(expm(Anegmulti{count}*(x(d)-B(count-1)))-eye(size(Anegmulti{count},1)))*Lnegmulti{count};(Aposmulti{count})\(expm((-Aposmulti{count})*(B(count)-x(d)))-expm((-Aposmulti{count})*(B(count)-B(count-1))))*Lposmulti{count}];
376 else
377 int=(1-(ga(count+1)))*coefficients{count}*[Lzeromulti{count}*(x(d)-0); Anegmulti{count}\‍(expm(Anegmulti{count}*(x(d)-0))-eye(size(Anegmulti{count},1)))*Lnegmulti{count};(Aposmulti{count})\(expm((-Aposmulti{count})*(B(count)-x(d)))-expm((-Aposmulti{count})*(B(count)-0)))*Lposmulti{count}];
378 end
379 for l=1:count
380 if l>1
381 ArrivalsWaitLessThanX(d,:)=ArrivalsWaitLessThanX(d,:)+successfulintegral(l-1,:);
382 end
383 end
384 ArrivalsWaitLessThanX(d,:)=ArrivalsWaitLessThanX(d,:)+int;
385 end
386
387 for r=1:length(zeromass)
388 ArrivalsWaitLessThanXmapped(:,r)=ArrivalsWaitLessThanX(:,r)*lmap(rem(r-1,2)+1);
389 IntegralMapped(:,r)=integral(:,r)*lmap(rem(r-1,2)+1);
390 AbandonIntegralMapped(:,r)=abandonintegral(:,r)*lmap(rem(r-1,2)+1);
391 WaitIntegralMapped(:,r)=waitintegral(:,r)*lmap(rem(r-1,2)+1);
392 ZeroMassMapped(r)=zeromass(r)*lmap(rem(r-1,2)+1);
393 end
394 normalization=SERVERSIZE*MAPSIZE;
395
396 w0=sum(ZeroMassMapped)/(sum(sum(IntegralMapped(:,1:normalization)))+sum(ZeroMassMapped));
397 AbandonProb=sum(sum(AbandonIntegralMapped(:,1:normalization)))/(sum(ZeroMassMapped)+sum(sum(IntegralMapped(:,1:normalization))));
398 w0s=sum(ZeroMassMapped)/((sum(sum(IntegralMapped(:,1:normalization)))+sum(ZeroMassMapped))*(1-AbandonProb));
399 ProbArrivalsWaitLessThan01=sum(ArrivalsWaitLessThanXmapped(1,1:normalization))/((sum(sum(IntegralMapped(:,1:normalization)))+sum(ZeroMassMapped))*(1-AbandonProb)*(1-w0s));
400 ProbArrivalsWaitLessThan02=sum(ArrivalsWaitLessThanXmapped(2,1:normalization))/((sum(sum(IntegralMapped(:,1:normalization)))+sum(ZeroMassMapped))*(1-AbandonProb)*(1-w0s));
401 ExpectedWait=sum(sum(WaitIntegralMapped(:,1:normalization)))/((sum(ZeroMassMapped)+sum(sum(IntegralMapped(:,1:normalization))))*(1-AbandonProb));
402
403 VarianceIntegral(1,:) =((B(1)/2)-ExpectedWait)^2*(1-(ga(2)))*coefficients{1}*[Lzeromulti{1}*(B(1)-0); Anegmulti{1}\‍(expm(Anegmulti{1}*((B(1)-0)))-eye(size(Anegmulti{1},1)))*Lnegmulti{1};(Aposmulti{1})\(eye(size(Aposmulti{1},1))-expm((-Aposmulti{1})*(B(1)-0)))*Lposmulti{1}];
404 for d=2:QUANTIZATION
405 VarianceIntegral(d,:) =(((B(d)+B(d-1))/2)-ExpectedWait)^2*(1-(ga(d+1)))*coefficients{d}*[Lzeromulti{d}*(B(d)-B(d-1)); Anegmulti{d}\‍(expm(Anegmulti{d}*((B(d)-B(d-1))))-eye(size(Anegmulti{d},1)))*Lnegmulti{d};(Aposmulti{d})\(eye(size(Aposmulti{d},1))-expm((-Aposmulti{d})*(B(d)-B(d-1))))*Lposmulti{d}];
406 end
407 for r=1:length(zeromass)
408 VarianceIntegralMapped(:,r)=VarianceIntegral(:,r)*lmap(rem(r-1,2)+1);
409 end
410 Variance=(sum(sum(VarianceIntegralMapped(:,1:normalization)))+sum(ZeroMassMapped)*ExpectedWait^2)/((sum(ZeroMassMapped)+sum(sum(IntegralMapped(:,1:normalization))))*(1-AbandonProb));
411
412 steadyStateResult=[w0 w0s AbandonProb ExpectedWait Variance ProbArrivalsWaitLessThan01 ProbArrivalsWaitLessThan02];
413
414 disp(' PR{W=0} PR{W=0|S} PR{A} E{W|S} Var{W|S} Fw|s,w>0(.1)Fw|s,w>0(.2)')
415 disp([w0 w0s AbandonProb ExpectedWait Variance ProbArrivalsWaitLessThan01 ProbArrivalsWaitLessThan02])
416
417 integral=[];
418 integrr=[];
419 integraa=[];
420 integrall=[];
421 integrass=[];
422 bound11=[];
423 denom=[];
424 nomin=[];
425 sumnomin=[];
426
427elseif SOLUTION==2
428 ca=boundaries{1};
429 cb=boundaries{end};
430 FirstPassageTimeofVirtual=(sum(cb))/ca(1)
431
432elseif SOLUTION==3
433 ca=boundaries{1};
434 FirstPassageTimeofActual=ca(1)/ca(2)
435end