1% D = RandomDMMAP(order, types, mean, zeroEntries, maxTrials, prec)
3% Returns a random discrete Markovian arrival process.
9% mean : double, optional
10% The mean inter-arrival times of the DMMAP
12% The number of different arrival types
13% zeroEntries : int, optional
14% The number of zero entries in the D0 and D1 matrices
15% maxTrials : int, optional
16% The maximum number of trials to find a proper DMMAP
17% (that has an irreducible phase process and none of
18% its parameters
is all-zero)
19% prec : double, optional
20% Numerical precision for checking the irreducibility.
21% The default value
is 1e-14.
25% D : list/cell of matrices of shape(M,M), length(types+1)
26% The D0...Dtypes matrices of the DMMAP
30% If it fails, try to increase the
'maxTrials' parameter,
31% or/and the
'mean' parameter.
33function D = RandomDMMAP(order, types, mean, zeroEntries, maxTrials, prec)
34% RandomDMMAP [ order, types, zeroEntries[0], prec[10^-14], maxTrials[100] ]
35% -> [ cell of matrix0, matrix1 .. matrixM ] :
36% Generates a random discrete time marked Markovian arrival process of
37% the given order and the given number of types. The obtained
38% representation containes
'zeroEntries' zeros. If it fails after
39%
'maxTrials' trials, then it decreases the number of zero entries. It
40% prints a message, if the found representation contains less zeros
41% than given.
'prec' is the numerical precision
43 if ~exist(
'zeroEntries',
'var')
47 if ~exist(
'mean',
'var')
51 if ~exist('prec','var')
55 if ~exist('maxTrials','var')
60 error('RandomMMAP: ''types'' must be positive integer!');
63 if zeroEntries > (order+1)*(order-1)+types*(order^2-1)
64 error('RandomDMAP/DMMAP: Too many zero entries requested! Try to decrease the zeroEntries parameter!');
67 % distribute the zero entries among the rows
68 function o = allZeroDistr (states, zeros)
74 x = allZeroDistr (states-1, zeros-iz);
76 xt = sort([x(jz,:), iz]);
77 % check if we have it already
80 if sum((o(kz,:)-xt).^2)==0
93 zeroDistr = allZeroDistr(order, zeroEntries);
96 while trials<maxTrials
97 % select a configuration from zeroDistr: it
is a list describing the zero entries in each row
98 zdix = randperm(size(zeroDistr,1));
99 for k=1:size(zeroDistr,1)
100 zDistr = zeroDistr(zdix(k),:);
102 for di=1:length(zDistr)
103 if zDistr(di)>=(types+1)*order-1;
112 B = zeros(order,(types+1)*order);
114 rp = randperm((types+1)*order-1);
115 a = zeros(1,(types+1)*order-1);
116 for j=1:(types+1)*order-1-zDistr(i)
119 B(i,1:i-1) = a(1:i-1);
120 B(i,i+1:end) = a(i:end);
122 % construct DMMAP matrices
126 D{i} = B(:,(i-1)*order+1:i*order);
127 sc = sc + sum(D{i},2);
133 D{i} = diag(1./sc)*D{i};
136 % check
if it
is a proper MAP (irreducible phase process & no full zero matrix)
141 if rank(D{1})==order && rank(eye(order)-sumD)==order-1
142 alpha = DTMCSolve(sumD);
143 if min(abs(alpha)) > prec
146 if all(all(D{i}==0.0))
152 % diagonals of matrix D0:
154 % scale to the mean value
155 Dv = cell(1,types+1);
157 Dv{i} = diag(1-d)*D{i};
159 Dv{1} = Dv{1}+diag(d);
160 m = MarginalMomentsFromDMMAP (Dv, 1);
161 d = 1 - (1-d)*m(1)/mean;
163 D{i} = diag(1-d)*D{i};
166 if CheckDMMAPRepresentation(D)
175 error(
'No feasible random DMAP/DMMAP found with such many zero entries! Try to increase the maxTrials parameter, or the mean value!');