LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Q_DT_SMK_ParsePara.m
1function Q_DT_SMK_ParsePara(C, C_name, processType)
2% Q_DT_SMK_Service_ParsePara checks the validity of the input cell C as a
3% representation of a Discrete-Time marked Semi-Markov process.
4%
5% If the SMK is a service process
6% C{k}=[Ck_1 Ck_2...Ck_tmax(k)], for k=1...K, where the entry (j,j') of
7% the mxm matrix Dk_i holds the probability that the service time of
8% a type-k customer takes i time slots (i=1:tmax(k)), while the
9% underlying phase changes from j to j'
10%
11% If the SMK is an arrival process
12% C{k}=[Ck_1 Ck_2...Ck_tmax(k)], for k=1...K, where the entry (j,j') of
13% the mxm matrix Ck_i, holds the probabilities of having a type k
14% arrival, with an interarrival time of i time slots (i=1:tmax(k)),
15% while the underlying phase changes from j to j'
16%
17% processType: equals 1 if the SM[K] process is an arrival process and 0
18% if it represents a service process
19
20
21if nargin < 3
22 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
23 'The type of the SM[K] process (arrival or service) has to be specified');
24end
25
26% check numeric
27K=size(C,2);
28for i=1:K
29 if (~isnumeric(C{i}))
30 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
31 'Matrix %s_%d has to be numeric', C_name, i);
32 end
33end
34
35% check real
36for i=1:K
37 if (~isreal(C{i}))
38 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
39 '%s_%d has to be a real matrix',C_name,i);
40 end
41end
42
43% check dimension
44for i=1:K
45 if (mod( size(C{i},2),size(C{i},1)) ~= 0)
46 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
47 '%s_%d is not a set of square matrices',C_name,i);
48 end
49end
50
51for i=1:K-1
52 if (size(C{i},1) ~= size(C{i+1},1))
53 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
54 'The matrices %s_%d and %s_d do not have the same number of rows',C_name,i,C_name,i+1);
55 end
56end
57
58% check nonnegativity
59for i=1:K
60 if (min(min(C{i})) < -10^(-14))
61 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
62 'The matrix %s_%d contains negative data',C_name,i);
63 end
64end
65
66% check stochasticity
67if processType == 0
68 Csum = cell(1,K);
69 m = size(C{1},1);
70 tmax = zeros(1,K);
71 for i = 1:K
72 tmax(i) = size(C{i},2)/m;
73 Csum{i} = reshape(sum(reshape(C{i}, m*m, tmax(i)), 2), m, m);
74 if (max(sum(Csum{i},2)) > 1+10^(-14))||(min(sum(Csum{i},2)) < 1-10^(-14))
75 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
76 'The matrix %s_%d(1)+%s_%d(2)...+%s_%d(%d) has to be stochastic', C_name,i,C_name,i,C_name,i,tmax(i));
77 end
78 end
79 % check that transition matrices Csum are equal for all types
80 for i = 1:K-1
81 if (max(max(abs(Csum{i+1}-Csum{i}))) > 10^(-14))
82 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
83 'The matrices %s_%d(1)+%s_%d(2)...+%s_%d(%d) and %s_%d(1)+%s_%d(2)...+%s_%d(%d)',...
84 'have to be identical ', C_name,i,C_name,i,C_name,i,tmax(i),C_name,i+1,C_name,i+1,C_name,i+1,tmax(i+1));
85 end
86 end
87else
88 %check stochasticity of the sum of the arrival matrices
89 m = size(C{1},1);
90 Csum = sum(C{1}, 2);
91 for i = 2:K
92 Csum = Csum + sum(C{i}, 2);
93 end
94 if (max(Csum) > 1+10^(-14))||(min(Csum) < 1-10^(-14))
95 error('MATLAB:Q_DT_SMK_ParsePara:InvalidInput',...
96 'The transition matrix of the embedded Markov chain of the semi-Markov process has to be stochastic');
97 end
98end