LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
SolverCTMC.m
1classdef SolverCTMC < NetworkSolver
2 % Continuous-Time Markov Chain solver for exact state-space analysis
3 %
4 % Implements exact analysis of queueing networks via CTMC formulation.
5 %
6 % Copyright (c) 2012-2026, Imperial College London
7 % All rights reserved.
8
9 methods
10 function self = SolverCTMC(model,varargin)
11 % SOLVERCTMC Create a CTMC solver instance
12 %
13 % @brief Creates a CTMC solver for exact Markov chain analysis
14 % @param model Network model to be analyzed via CTMC formulation
15 % @param varargin Optional parameters (cutoff, method, etc.)
16 % @return self SolverCTMC instance configured for exact analysis
17 self@NetworkSolver(model, mfilename);
18 self.setOptions(Solver.parseOptions(varargin, self.defaultOptions));
19 self.setLang();
20 end
21
22 runtime = runAnalyzer(self, options)
23 Pnir = getProb(self, node, state)
24 Pn = getProbSys(self)
25 Pnir = getProbAggr(self, ist)
26
27 Pn = getProbSysAggr(self)
28 [Pi_t, SSsysa] = getTranProbSysAggr(self)
29 [Pi_t, SSnode_a] = getTranProbAggr(self, node)
30 [Pi_t, SSsys] = getTranProbSys(self)
31 [Pi_t, SSnode] = getTranProb(self, node)
32 RD = getCdfRespT(self, R)
33 RD = getCdfSysRespT(self)
34
35 [stateSpace,nodeStateSpace] = getStateSpace(self, options)
36 stateSpaceAggr = getStateSpaceAggr(self)
37
38 % Reward computation methods
39 [t, V, names, stateSpace] = getReward(self, rewardName)
40 [R, names] = getAvgReward(self)
41 [V, t, names, stateSpace] = runRewardAnalyzer(self)
42
43 function [state_space, local_states] = stateSpace(self)
44 % STATESPACE Kotlin-style alias for getStateSpace
45 if nargout <= 1
46 state_space = self.getStateSpace();
47 else
48 [state_space, local_states] = self.getStateSpace();
49 end
50 end
51
52 function Q = generator(self)
53 % GENERATOR Kotlin-style alias for getGenerator
54 Q = self.getGenerator();
55 end
56
57 [infGen, eventFilt, synchInfo, stateSpace, nodeStateSpace] = getSymbolicGenerator(self, invertSymbol, primeNumbers)
58 [infGen, eventFilt, synchInfo] = getInfGen(self, options)
59 [infGen, eventFilt, synchInfo] = getGenerator(self, options)
60
61 tstate = sampleSys(self, numevents)
62 sampleAggr = sampleAggr(self, node, numSamples)
63
64 function MCTMC = getMarkedCTMC(self, options)
65 % MCTMC = GETMARKEDCTMC(options)
66
67 if nargin < 2
68 [infGen, eventFilt, synchInfo] = self.getInfGen();
69 else
70 [infGen, eventFilt, synchInfo] = getInfGen(self, options);
71 end
72
73 MCTMC = MarkedMarkovProcess(infGen, eventFilt, synchInfo);
74 end
75
76 function sn = getStruct(self)
77 % QN = GETSTRUCT()
78
79 % Get data structure summarizing the model
80 sn = self.model.getStruct(true);
81 end
82
83
84 function [allMethods] = listValidMethods(self)
85 % allMethods = LISTVALIDMETHODS()
86 % List valid methods for this solver
87 sn = self.model.getStruct();
88 allMethods = {'default','gpu'};
89 end
90 end
91
92 methods (Static)
93
94 function featSupported = getFeatureSet()
95 % FEATSUPPORTED = GETFEATURESET()
96
97 featSupported = SolverFeatureSet;
98 featSupported.setTrue({'Source','Sink',...
99 'ClassSwitch','Delay','DelayStation','Queue',...
100 'MAP','APH','MMPP2','PH','Coxian','Erlang','Exp','HyperExp',...
101 'Det','Gamma','Lognormal','Pareto','Uniform','Weibull',...
102 'StatelessClassSwitcher','InfiniteServer','SharedServer','Buffer','Dispatcher',...
103 'Cache','CacheClassSwitcher', ...
104 'Server','JobSink','RandomSource','ServiceTunnel',...
105 'SchedStrategy_INF','SchedStrategy_PS',...
106 'SchedStrategy_DPS','SchedStrategy_GPS',...
107 'SchedStrategy_SIRO','SchedStrategy_SEPT',...
108 'SchedStrategy_LEPT','SchedStrategy_FCFS',...
109 'SchedStrategy_HOL','SchedStrategy_LCFS',...
110 'SchedStrategy_LCFSPR',...
111 'RoutingStrategy_RROBIN',...
112 'RoutingStrategy_PROB','RoutingStrategy_RAND',...
113 'ReplacementStrategy_RR', 'ReplacementStrategy_FIFO','ReplacementStrategy_SFIFO','ReplacementStrategy_LRU',...
114 'ClosedClass','SelfLoopingClass','OpenClass','Replayer'});
115 end
116
117 function [bool, featSupported, featUsed] = supports(model)
118 % [BOOL, FEATSUPPORTED, FEATUSED] = SUPPORTS(MODEL)
119
120 featUsed = model.getUsedLangFeatures();
121 featSupported = SolverCTMC.getFeatureSet();
122 bool = SolverFeatureSet.supports(featSupported, featUsed);
123 end
124
125 function options = defaultOptions()
126 % OPTIONS = DEFAULTOPTIONS()
127 options = SolverOptions('CTMC');
128 end
129
130 function printInfGen(Q,SS)
131 % PRINTINFGEN(Q,SS)
132
133 SS=full(SS);
134 Q=full(Q);
135 for s=1:size(SS,1)
136 for sp=1:size(SS,1)
137 if Q(s,sp)>0
138 line_printf('\n%s->%s: %f',mat2str(SS(s,:)),mat2str(SS(sp,:)),double(Q(s,sp)));
139 end
140 end
141 end
142 line_printf('\n');
143 end
144
145 function printEventFilt(sync,D,SS,myevents)
146 % PRINTEVENTFILT(SYNC,D,SS,MYEVENTS)
147
148 if nargin<4 %~exist('events','var')
149 myevents = 1:length(sync);
150 end
151 SS=full(SS);
152 for e=myevents
153 D{e}=full(D{e});
154 for s=1:size(SS,1)
155 for sp=1:size(SS,1)
156 if D{e}(s,sp)>0
157 line_printf('\n%s-- %d: (%d,%d) => (%d,%d) -->%s: %f',mat2str(SS(s,:)),e,sync{e}.active{1}.node,sync{e}.active{1}.class,sync{e}.passive{1}.node,sync{e}.passive{1}.class,mat2str(SS(sp,:)),double(D{e}(s,sp)));
158 end
159 end
160 end
161 end
162 end
163
164 function libs = getLibrariesUsed(sn, options)
165 % GETLIBRARIESUSED Get list of external libraries used by CTMC solver
166 % CTMC uses internal solving functions, no external library attribution needed
167 libs = {};
168 end
169 end
170end