LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MStaircase.m
1% [B, n] = MStaircase(X, Z, precision)
2%
3% Computes a smaller representation using the staircase
4% algorithm.
5%
6% Notes
7% -----
8% This function should not be called directly.
9% It is used by 'MinimalRepFromME' and 'MinimalRepFromRAP'.
10%
11% References
12% ----------
13% .. [1] P. Buchholz, M. Telek, "On minimal representation
14% of rational arrival processes." Madrid Conference
15% on Qeueuing theory (MCQT), June 2010.
16
17function [B,n] = MStaircase (X,Z, precision)
18
19 if nargin<3
20 precision = 1e-8;
21 end
22
23 msize = length(X);
24 m = size(X{1},1);
25 U = eye(m);
26
27
28 ranksum=0; %The sum of the ranks calculated in every loop
29 crit=1; %The stopping criteria
30 while crit
31 r=rank(Z,precision);
32 ranksum=ranksum+r;
33 [Ui,S,T] = svd(Z);
34
35 %Calculation of the new U,X,Z matrices
36 Transf=eye(ranksum-r+size(Ui,1));
37 Transf(end-size(Ui,1)+1:end,end-size(Ui,1)+1:end)=Ui';
38 U=(Transf*U')';
39
40 for ii=1:msize
41 TEMP = Ui'*X{ii}*Ui;
42 X{ii} = TEMP(r+1:end,r+1:end);
43 if ii==1
44 Z = TEMP(r+1:end,1:r);
45 else
46 Z = horzcat(Z,TEMP(r+1:end,1:r));
47 end
48 end
49
50 if norm(Z)<precision || rank(Z,precision)==m-ranksum
51 crit=0;
52 end
53 end
54
55 n=ranksum;
56 I=eye(m,m);
57 if norm(Z)<precision
58 n=ranksum;
59 x=sum(U',2);
60 x=x(1:n);
61
62 %does x have a 0 value somewhere
63 yes=0;
64 zeroloc=zeros(n,1);
65 nonzero=0; %this will indicate a row of x for which x's value is non-zero
66 for l=1:n
67 if abs(x(l))<precision
68 yes=1;
69 zeroloc(l,1)=1;
70 elseif nonzero==0
71 nonzero=l;
72 end
73 end
74
75 R=eye(n,n);
76 if yes
77 for l=1:n;
78 if zeroloc(l,1)==1;
79 R(l,nonzero)=1;
80 end
81 end
82 end
83
84 y=R*x;
85 Gamma=diag(y);
86 TEMP1=I;
87 TEMP1(1:n,1:n)=inv(Gamma);
88 TEMP2=I;
89 TEMP2(1:n,1:n)=R;
90 B=inv(TEMP1*TEMP2*U');
91 elseif rank(Z,precision)==m-ranksum
92 B=I;
93 n=m;
94 end
95end