LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
lossn_erlangfp.m
1%{ @file lossn_erlangfp.m
2 % @brief Erlang fixed point approximation for loss networks
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes performance metrics for loss networks using Erlang FP
9 %
10 % @details
11 % This function uses the Erlang fixed point approximation to compute
12 % performance metrics for loss networks. Calls on route r arrive according
13 % to Poisson rate nu_r with unit mean service times. Link capacity
14 % requirements are: sum_r A(j,r) n(j,r) <= C(j) for all links j.
15 %
16 % @par Syntax:
17 % @code
18 % [QLen, Loss, E, niter] = lossn_erlangfp(nu, A, C)
19 % @endcode
20 %
21 % @par Parameters:
22 % <table>
23 % <tr><th>Name<th>Description
24 % <tr><td>nu<td>Arrival rate of route (class) r (1xR vector)
25 % <tr><td>A<td>Capacity requirement of link j for route r (JxR matrix)
26 % <tr><td>C<td>Available capacity of link j (Jx1 vector)
27 % </table>
28 %
29 % @par Returns:
30 % <table>
31 % <tr><th>Name<th>Description
32 % <tr><td>QLen<td>Mean queue-length for route r
33 % <tr><td>Loss<td>Loss probability for route r
34 % <tr><td>E<td>Blocking probability for link j
35 % <tr><td>niter<td>Number of iterations required for convergence
36 % </table>
37%}
38function [QLen,Loss,E,niter] = lossn_erlangfp(nu,A,C)
39% [QLen,Loss,E] = LOSS_ERLANGFP(rho,A,C)
40% Erlang fixed point approximation for loss networks
41%
42% Calls (i.e., jobs) on route (i.e., class) r arrive according to Poisson
43% rate nu_r, r=1..R. Call service times on route r have unit mean.
44%
45% Link capacity requirements are:
46% \sum_r A(j,r) n(j,r) <= C(j)
47% for all links j=1..J, where n(j,r) counts the calls on route r on link j.
48%
49% INPUT:
50% nu (1xR): arv. rate of route (class) r = 1..R
51% A (J,R): capacity requirement of link j for route r = 1..R
52% C (J,1): available capacity of link j
53%
54% OUTPUT:
55% Q (1xR): mean queue-length for route r = 1..R calls
56% L (1xR): loss probability for route r = 1..R calls
57% E (Jx1): blocking probability of for link j = 1..J
58%
59% NOTE: nu_r may be replaced by a utilization rho_r=nu_r/mu_r, where mu_r
60% is the service rate for route r.
61
62R = length(nu);
63J = length(C);
64E = 0.5*ones(J,1);
65E_1 = 0*ones(J,1);
66niter = 0;
67while norm(E-E_1,1)>1e-8 && niter<10000
68 niter = niter + 1;
69 E_1 = E;
70 for j=1:J
71 rhoj_1 = 0;
72 for r=1:R
73 if A(j,r)>0
74 termj=nu(r)*A(j,r);
75 for i=1:J
76 if A(i,r)>0
77 termj=termj*(1-E_1(i))^A(i,r);
78 end
79 end
80 rhoj_1 = rhoj_1 + termj;
81 end
82 end
83 rhoj_1 = rhoj_1 / (1-E_1(j));
84 E(j) = ErlangB(rhoj_1,C(j));
85 end
86end
87QLen = nu;
88for r=1:R
89 for j=1:J
90 QLen(r) = QLen(r)*(1-E(j))^A(j,r);
91 end
92end
93QLen = real(QLen);
94Loss = QLen./nu;
95end
96
97function blockProb = ErlangB(nu,C)
98% Erlang B formula
99% blockProb = E(nu,C) = (nu^C/C!) / (sum_{i=1}^C nu^i/i!)
100den = 0;
101for i=0:C
102 d = i*log(nu)-factln(i);
103 den = den + exp(d);
104end
105blockProb = C*log(nu) -factln(C) -log(den);
106blockProb = exp(blockProb);
107end