LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
TaylorSeriesClassic.m
1classdef TaylorSeriesClassic < handle
2 properties (Access = private)
3 h = 0.0
4 B
5 is_process_not_binded = true
6 end
7
8 methods
9 function obj = TaylorSeriesClassic(proc, order, step)
10 if nargin > 0
11 if nargin < 3
12 step = -1.0;
13 end
14 obj.bind(proc, order, step);
15 end
16 end
17
18 function bind(obj, proc, order, step)
19 if nargin < 4
20 step = -1.0;
21 end
22
23 if step < 0
24 obj.h = step / proc.get_min_element();
25 elseif step > 0
26 obj.h = step;
27 else
28 libqbd.raise_error('step must be not equal 0.');
29 end
30
31 obj.B = libqbd.QInPow(proc);
32 obj.B = obj.B.mull_by_const(obj.h);
33 obj.compute_right_matrix(order);
34 obj.is_process_not_binded = false;
35 end
36
37 function value = get_step(obj)
38 obj.check();
39 value = obj.h;
40 end
41
42 function dist = get_dist(obj, max_time, pi_0)
43 obj.check();
44 pi = pi_0;
45 dist = {pi};
46 time = 0.0;
47 while true
48 pi = obj.B.mull_by_vector(pi);
49 dist{end + 1} = pi;
50 time = time + obj.h;
51 if time > max_time
52 break;
53 end
54 end
55 end
56
57 function values = get_mean_clients(obj, max_time, pi_0)
58 obj.check();
59 pi = pi_0;
60 values = obj.compute_clients(pi);
61 time = 0.0;
62 while true
63 pi = obj.B.mull_by_vector(pi);
64 values(end + 1) = obj.compute_clients(pi); %#ok<AGROW>
65 time = time + obj.h;
66 if time > max_time
67 break;
68 end
69 end
70 end
71
72 function values = get_mean_queue(obj, queue_size_vector, max_time, pi_0)
73 obj.check();
74 pi = pi_0;
75 values = obj.compute_queue(queue_size_vector, pi);
76 time = 0.0;
77 while true
78 pi = obj.B.mull_by_vector(pi);
79 values(end + 1) = obj.compute_queue(queue_size_vector, pi); %#ok<AGROW>
80 time = time + obj.h;
81 if time > max_time
82 break;
83 end
84 end
85 end
86 end
87
88 methods (Access = private)
89 function check(obj)
90 if obj.is_process_not_binded
91 libqbd.raise_error('Not binded to the process.');
92 end
93 obj.B.check();
94 end
95
96 function compute_right_matrix(obj, order)
97 order = min(order, libqbd.get_max_factor());
98 P = obj.B;
99 for k = 1:(order - 1)
100 P = P.inc_power(obj.h);
101 tmp = P.mull_by_const(libqbd.get_one_div_by_factor(k));
102 obj.B = obj.B.plus_assign(tmp);
103 end
104 obj.B = obj.B.add_identity_matrix();
105 end
106
107 function value = compute_clients(~, pi)
108 value = 0.0;
109 for k = 2:numel(pi)
110 value = value + (k - 1) * sum(pi{k});
111 end
112 end
113
114 function value = compute_queue(~, queue_size_vector, pi)
115 value = 0.0;
116 qvec = libqbd.as_row_vector(queue_size_vector{1});
117 for k = 2:numel(pi)
118 if k <= numel(queue_size_vector)
119 qvec = libqbd.as_row_vector(queue_size_vector{k});
120 else
121 qvec = qvec + 1.0;
122 end
123 value = value + sum(libqbd.as_row_vector(pi{k}) .* qvec);
124 end
125 end
126 end
127end