1function sampleResult = sampleAggr(self, node, numSamples)
2% SAMPLERESULT = SAMPLEAGGR(NODE, NUMSAMPLES) Returns aggregated sample path at a node
4% @brief Generates a discrete-
event sample path with state aggregated over phases
6% This method runs a DES transient simulation and records the sequence
7% of states visited at a specified station, with states aggregated to
8% show only the number of jobs per
class (not per-phase details).
10% @param self SolverDES instance
11% @param node Queue or node
object to sample
12% @param numSamples Number of time points to sample
14% @
return sampleResult Structure containing the aggregated sample path with fields:
15% - sampleResult.handle: Reference to the sampled node
16% - sampleResult.t: Vector of time points
17% - sampleResult.state: Matrix of aggregated states (jobs per class)
18% - sampleResult.event: Cell array of events
19% - sampleResult.isaggregate: Boolean true (aggregated sample)
21% @see sample - Returns detailed sample path with phase information
22% @see sampleSysAggr - Returns aggregated system-wide sample path
26% model = Network(
'MM1');
27% % ... model setup ...
28% solver = SolverDES(model,
'seed', 42);
29% queue = model.nodes{1};
30% result = solver.sampleAggr(queue, 1000);
34 line_error(mfilename,
'sampleAggr requires to specify a station.');
38 numSamples = self.options.samples;
41% Convert model to Java
42jmodel = LINE2JLINE(self.model);
44% Create Java DES options
45joptions = jline.solvers.des.DESOptions();
46joptions.samples = self.options.samples;
47joptions.seed = self.options.seed;
50jsolver = jline.solvers.des.SolverDES(jmodel, joptions);
52% Get stateful node from model
53sn = self.model.getStruct;
60% Find the corresponding Java node
61statefulNodes = jmodel.getStatefulNodes();
62isf = sn.nodeToStateful(nodeIdx);
63jnode = statefulNodes.get(isf - 1); % Java
is 0-indexed
65% Call Java sampleAggr method
66jresult = jsolver.sampleAggr(jnode, numSamples);
68% Convert Java result to MATLAB structure
69sampleResult = struct();
70sampleResult.handle = node;
74 sampleResult.t = JLINE.from_jline_matrix(jresult.t);
80if ~isempty(jresult.state) && isa(jresult.state, 'jline.util.matrix.Matrix')
81 sampleResult.state = JLINE.from_jline_matrix(jresult.state);
83 sampleResult.state = [];
87if ~isempty(jresult.event) && isa(jresult.event, 'jline.util.matrix.Matrix')
88 sampleResult.event = JLINE.from_jline_matrix(jresult.event);
90 sampleResult.event = {};
93sampleResult.isaggregate = jresult.isAggregate;
94sampleResult.nodeIndex = nodeIdx;
95sampleResult.numSamples = jresult.numSamples;