LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getProbSys.m
1function ProbSys = getProbSys(self)
2% PROBSYS = GETPROBSYS()
3% Joint steady-state probability of the current system state, estimated as the
4% time-weighted fraction of the system-wide simulated trajectory in that joint
5% state. Fully JSON-mediated (via sampleSys()). Mirrors Python-native getProbSys().
6
7if GlobalConstants.DummyMode
8 ProbSys = NaN;
9 return
10end
11
12sysResult = self.sampleSys(0);
13if isempty(sysResult) || ~isstruct(sysResult) || isempty(sysResult.t)
14 ProbSys = 0;
15 return
16end
17
18t = sysResult.t(:);
19states = sysResult.state;
20nt = numel(t);
21if nt < 2 || isempty(states)
22 ProbSys = 0;
23 return
24end
25
26sn = self.model.getStruct;
27nstateful = numel(states);
28targets = cell(1, nstateful);
29for isf = 1:nstateful
30 if iscell(sn.state) && numel(sn.state) >= isf && ~isempty(sn.state{isf})
31 targets{isf} = sn.state{isf}(:).';
32 else
33 targets{isf} = zeros(1, size(states{isf}, 2));
34 end
35end
36
37total = t(end) - t(1);
38if total <= 0
39 ProbSys = 0;
40 return
41end
42
43timeInState = 0;
44for ti = 1:nt-1
45 dt = t(ti+1) - t(ti);
46 allMatch = true;
47 for isf = 1:nstateful
48 L = min(numel(targets{isf}), size(states{isf}, 2));
49 if ~all(abs(states{isf}(ti, 1:L) - targets{isf}(1:L)) < 1e-10)
50 allMatch = false;
51 break
52 end
53 end
54 if allMatch
55 timeInState = timeInState + dt;
56 end
57end
58ProbSys = timeInState / total;
59end
Definition Station.m:245