LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleSys.m
1function tranSysState = sampleSys(self, numSamples)
2% TRANSYSSTATE = SAMPLESYS(NUMSAMPLES) Returns system-wide sample path
3%
4% @brief Generates a discrete-event sample path for all stateful nodes
5%
6% This method runs a DES transient simulation and records the sequence
7% of states visited at all stateful nodes in the network.
8%
9% @param self SolverDES instance
10% @param numSamples Number of time points to sample
11%
12% @return tranSysState Structure containing the system-wide sample path with fields:
13% - tranSysState.handle: Cell array of stateful node handles
14% - tranSysState.t: Vector of time points
15% - tranSysState.state: Cell array of state matrices (one per node)
16% - tranSysState.event: Cell array of events
17% - tranSysState.isaggregate: Boolean false (detailed sample)
18%
19% @see sampleSysAggr - Returns system-wide sample path aggregated over phases
20% @see sample - Returns sample path for a single node
21%
22% Example:
23% @code
24% model = Network('MM1');
25% % ... model setup ...
26% solver = SolverDES(model, 'seed', 42);
27% result = solver.sampleSys(1000);
28% @endcode
29
30if nargin < 2
31 numSamples = self.options.samples;
32end
33
34% Convert model to Java
35jmodel = LINE2JLINE(self.model);
36
37% Create Java DES options
38joptions = jline.solvers.des.DESOptions();
39joptions.samples = self.options.samples;
40joptions.seed = self.options.seed;
41
42% Create Java solver
43jsolver = jline.solvers.des.SolverDES(jmodel, joptions);
44
45% Call Java sampleSys method
46jresult = jsolver.sampleSys(numSamples);
47
48% Convert Java result to MATLAB structure
49tranSysState = struct();
50tranSysState.handle = self.model.getStatefulNodes';
51
52% Convert time matrix
53if ~isempty(jresult.t)
54 tranSysState.t = JLINE.from_jline_matrix(jresult.t);
55else
56 tranSysState.t = [];
57end
58
59% Convert state - it's a List<Matrix> in Java, convert to cell array
60sn = self.model.getStruct;
61if ~isempty(jresult.state) && isa(jresult.state, 'java.util.List')
62 nstateful = jresult.state.size();
63 tranSysState.state = cell(1, nstateful);
64 for isf = 1:nstateful
65 jmatrix = jresult.state.get(isf - 1); % Java is 0-indexed
66 if ~isempty(jmatrix) && isa(jmatrix, 'jline.util.matrix.Matrix')
67 tranSysState.state{isf} = JLINE.from_jline_matrix(jmatrix);
68 else
69 tranSysState.state{isf} = [];
70 end
71 end
72else
73 tranSysState.state = {};
74end
75
76% Convert event matrix
77if ~isempty(jresult.event) && isa(jresult.event, 'jline.util.matrix.Matrix')
78 tranSysState.event = JLINE.from_jline_matrix(jresult.event);
79else
80 tranSysState.event = {};
81end
82
83tranSysState.isaggregate = jresult.isAggregate;
84tranSysState.numSamples = jresult.numSamples;
85
86end
Definition mmt.m:92