LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
FindMarkovianRepresentation.m
1% mrep = FindMarkovianRepresentation(rep, @transfun, @evalfunc, precision)
2%
3% Obtains a Markovian representation from a non-Markovian
4% one while keeping the size the same, by applying a series
5% of elementary transformations.
6%
7% Parameters
8% ----------
9% rep : tuple of matrices
10% The initial non-Markovian representation
11% (initial vector and generator of a PH, matrices of a
12% MAP, or a MMAP, etc.)
13% transfun : callable
14% A function that transforms the representation using
15% the given similarity transformation matrix
16% evalfunc : callable
17% A function that returns how far the representation is
18% from the Markovian one
19% precision : double
20% A representation is considered to be a Markovian one
21% if it is closer than the precision. The default value
22% is 1e-7
23%
24% Returns
25% -------
26% mrep : tuple of matrices
27% The Markovian representation, if found. If not found,
28% the closest one is returned.
29%
30% Notes
31% -----
32% This function should not be called directly.
33% It is used by 'PHFromME', 'MAPFromRAP', etc. functions.
34%
35% References
36% ----------
37% .. [1] G Horváth, M Telek, "A minimal representation of
38% Markov arrival processes and a moments matching
39% method," Performance Evaluation 64:(9-12)
40% pp. 1153-1168. (2007)
41
42function nrep = FindMarkovianRepresentation (rep, transfun, evalfun, precision)
43
44 if ~exist('precision','var')
45 precision = 1e-7;
46 end
47
48 function [bestrep, bestdist] = elementary (erep, b, k, evalfun, transfun)
49 bestdist = evalfun (erep, k);
50 bestrep = erep;
51 repSize = size(erep{1},2);
52 for i=1:repSize
53 for j=1:repSize
54 if i~=j
55 % create elementary transformation matrix with +b
56 B = eye(repSize);
57 B(i,j) = b;
58 B(i,i) = 1.0 - b;
59 % apply similarity transform
60 newrep = transfun (erep, B);
61 newdist = evalfun (newrep, k);
62 % store result if better
63 if newdist < bestdist
64 bestrep = newrep;
65 bestdist = newdist;
66 end
67 % create elementary transformation matrix with -b
68 B = eye(repSize);
69 B(i,j) = -b;
70 B(i,i) = 1.0 + b;
71 % apply similarity transform
72 newrep = transfun (erep, B);
73 newdist = evalfun (newrep, k);
74 % store result if better
75 if newdist < bestdist
76 bestrep = newrep;
77 bestdist = newdist;
78 end
79 end
80 end
81 end
82 end
83
84 function [bestrep, lastdist] = minimize (orep, iters, b, k, evalfun, transfun)
85 lastdist = evalfun (orep, k);
86 bestrep = orep;
87 for i=1:iters
88 [orep, dist] = elementary (orep, b, k, evalfun, transfun);
89 if dist >= lastdist
90 break;
91 else
92 lastdist = dist;
93 bestrep = orep;
94 end
95 end
96 end
97
98 if evalfun(rep) < precision
99 nrep = rep;
100 return;
101 end
102
103 nrep = rep;
104 M = size(nrep{1},2);
105 b = 0.5;
106 odist = inf;
107 while b>precision/2
108 for m=1:M*M
109 for k=1:4
110 [nrep, ddist] = minimize (nrep, M*M, b, k, evalfun, transfun);
111 if ddist < precision
112 return;
113 end
114 end
115 if odist <= ddist
116 break;
117 end
118 odist = ddist;
119 end
120 b = b / 2.0;
121 end
122end