1function tranSysState = sampleSys(self, numSamples)
2% TRANSYSSTATE = SAMPLESYS(NUMSAMPLES) Returns system-wide sample path
4% @brief Generates a discrete-
event sample path
for all stateful
nodes
6% This method runs a DES transient simulation and records the sequence
7% of states visited at all stateful
nodes in the network.
9% @param self SolverDES instance
10% @param numSamples Number of time points to sample
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)
19% @see sampleSysAggr - Returns system-wide sample path aggregated over phases
20% @see sample - Returns sample path
for a single node
24% model = Network(
'MM1');
25% % ... model setup ...
26% solver = SolverDES(model,
'seed', 42);
27% result = solver.sampleSys(1000);
31 numSamples = self.options.samples;
34% Convert model to Java
35jmodel = LINE2JLINE(self.model);
37% Create Java DES options
38joptions = jline.solvers.des.DESOptions();
39joptions.samples = self.options.samples;
40joptions.seed = self.options.seed;
43jsolver = jline.solvers.des.SolverDES(jmodel, joptions);
45% Call Java sampleSys method
46jresult = jsolver.sampleSys(numSamples);
48% Convert Java result to MATLAB structure
49tranSysState =
struct();
50tranSysState.handle = self.model.getStatefulNodes
';
54 tranSysState.t = JLINE.from_jline_matrix(jresult.t);
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);
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);
69 tranSysState.state{isf} = [];
73 tranSysState.state = {};
77if ~isempty(jresult.event) && isa(jresult.event,
'jline.util.matrix.Matrix')
78 tranSysState.event = JLINE.from_jline_matrix(jresult.event);
80 tranSysState.event = {};
83tranSysState.isaggregate = jresult.isAggregate;
84tranSysState.numSamples = jresult.numSamples;