LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getProbAggr.m
1function ProbAggr = getProbAggr(self, node, state)
2% PROBAGGR = GETPROBAGGR(NODE, STATE) Returns aggregated state probability via DES simulation
3%
4% @brief Estimates steady-state aggregated (per-class) state probabilities via DES simulation
5%
6% This method estimates the probability of observing a specific per-class job distribution
7% (e.g., [2 jobs of class 1, 1 job of class 2]) at a station. States are aggregated over
8% service phases - only the number of jobs per class matters.
9%
10% @param self SolverDES instance
11% @param node Queue or node object (or node index as integer)
12% @param state (optional) Aggregated state specification as vector (per-class job counts).
13% If omitted, uses current network state aggregated over phases.
14%
15% @return ProbAggr Estimated aggregated state probability value
16% - 0 if state not seen during simulation (rare event)
17%
18% @note DES estimates probabilities from finite simulation. Accuracy improves with
19% more samples.
20%
21% @warning Simulation-based estimate - results vary between runs unless seed is set.
22%
23% @see getProb - Returns phase-detailed state probabilities
24% @see getProbSysAggr - Returns joint aggregated system state probabilities
25%
26% Example:
27% @code
28% solver = SolverDES(model, 'samples', 50000, 'seed', 42);
29% queue1 = model.nodes{1};
30%
31% % Estimate probability of having 3 class-1 jobs and 2 class-2 jobs
32% prob_aggr = solver.getProbAggr(queue1, [3, 2]);
33% fprintf('Estimated Pr[n1=3, n2=2] = %.4f\n', prob_aggr);
34% @endcode
35
36if GlobalConstants.DummyMode
37 ProbAggr = NaN;
38 return
39end
40
41% Convert model to Java
42jmodel = LINE2JLINE(self.model);
43
44% Create Java DES options
45joptions = jline.solvers.des.DESOptions();
46joptions.samples = self.options.samples;
47joptions.seed = self.options.seed;
48
49% Create Java solver
50jsolver = jline.solvers.des.SolverDES(jmodel, joptions);
51
52% Get stateful node from model
53sn = self.model.getStruct;
54if isa(node, 'Node')
55 nodeIdx = node.index;
56else
57 nodeIdx = node;
58end
59
60% Find the corresponding Java node
61statefulNodes = jmodel.getStatefulNodes();
62isf = sn.nodeToStateful(nodeIdx);
63jnode = statefulNodes.get(isf - 1); % Java is 0-indexed
64
65% Convert state to Java Matrix if provided
66if nargin < 3 || isempty(state)
67 jstate = [];
68else
69 jstate = JLINE.to_jline_matrix(state(:)');
70end
71
72% Call Java getProbAggr method and extract probability value
73if isempty(jstate)
74 jresult = jsolver.getProbAggr(jnode);
75else
76 jresult = jsolver.getProbAggr(jnode, jstate);
77end
78
79% Extract the probability value from the ProbabilityResult object
80ProbAggr = jresult.probability;
81
82end
Definition mmt.m:92