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