1% D = RandomMMAP(order, types, mean, zeroEntries, maxTrials, prec)
3% Returns a random Markovian arrival process with given mean
11% The number of different arrival types
12% mean : double, optional
13% The mean inter-arrival times of the
MMAP
14% zeroEntries : int, optional
15% The number of zero entries in the D0 and D1 matrices
16% maxTrials : int, optional
17% The maximum number of trials to find a proper
MMAP
18% (that has an irreducible phase process and none of
19% its parameters
is all-zero)
20% prec : double, optional
21% Numerical precision for checking the irreducibility.
22% The default value
is 1e-14.
26% D : list/cell of matrices of shape(M,M), length(types+1)
27% The D0...Dtypes matrices of the
MMAP
29function D = RandomMMAP(order, types, mean, zeroEntries, maxTrials, prec)
31 if ~exist(
'zeroEntries',
'var')
35 if ~exist(
'mean',
'var')
39 if ~exist('prec','var')
43 if ~exist('maxTrials','var')
48 error('RandomMMAP: ''types'' must be positive integer!');
51 if zeroEntries > (types+1)*order^2 - 2*order
52 error('RandomMAP/
MMAP: Too many zero entries requested! Try to decrease the zeroEntries parameter!');
55 % distribute the zero entries among the rows
56 function o = allZeroDistr (states, zeros)
62 x = allZeroDistr (states-1, zeros-iz);
64 xt = sort([x(jz,:), iz]);
65 % check if we have it already
68 if sum((o(kz,:)-xt).^2)==0
81 zeroDistr = allZeroDistr(order, zeroEntries);
84 while trials<maxTrials
85 % select a configuration from zeroDistr: it
is a list describing the zero entries in each row
86 zdix = randperm(size(zeroDistr,1));
87 for k=1:size(zeroDistr,1)
88 zDistr = zeroDistr(zdix(k),:);
90 for di=1:length(zDistr)
91 if zDistr(di)>=(types+1)*order-1;
100 B = zeros(order,(types+1)*order);
102 rp = randperm((types+1)*order-1);
103 a = zeros(1,(types+1)*order-1);
104 for j=1:(types+1)*order-1-zDistr(i)
107 B(i,1:i-1) = a(1:i-1);
108 B(i,i+1:end) = a(i:end);
110 % construct
MMAP matrices
113 D{i} = B(:,(i-1)*order+1:i*order);
115 D{1} = D{1} - diag(sum(B,2));
116 % check
if it
is a proper MAP (irreducible phase process & no full zero matrix)
121 if rank(D{1})==order && rank(sumD)==order-1
122 alpha = CTMCSolve(sumD);
123 if min(abs(alpha)) > prec
126 if all(all(D{i}==0.0))
132 % scale to the mean value
133 m = MarginalMomentsFromMMAP(D, 1);
135 D{i} = D{i} * m / mean;
144 error(
'No feasible random MAP/MMAP found with such many zero entries! Try to increase the maxTrials parameter!');