LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getProbAggr.m
1function Pnir = getProbAggr(self, node, state_a)
2% PNIR = GETPROBAGGR(NODE, STATE_A)
3%
4% Probability of a SPECIFIC per-class job distribution at a station.
5% Returns P(n1 jobs of class 1, n2 jobs of class 2, ...) at the node.
6%
7% Compare with getProbMarg: returns total queue-length distribution,
8% i.e., P(n total jobs) summed over all class combinations.
9%
10% Input:
11% node - Queue or node object
12% state_a - Per-class job counts, e.g., [2,1] = 2 class-1, 1 class-2
13%
14% Output:
15% Pnir - Scalar probability in [0,1]
16
17if GlobalConstants.DummyMode
18 Pnir = NaN;
19 return
20end
21
22T0 = tic;
23sn = self.model.getStruct(true); % sync node states into sn.state
24
25% Get unnormalized probability using original NC method
26ist = sn.nodeToStation(node.index);
27isf = sn.nodeToStateful(node.index);
28if nargin<3
29 state_a = sn.state{isf};
30else
31 % state_a is a per-class marginal count vector; convert it to the
32 % internal state encoding expected by State.toMarginal, and store it
33 % under the stateful index used by solver_nc_margaggr
34 state_a = State.fromMarginal(sn, node.index, state_a);
35end
36
37% Store original state and set requested state
38original_state = sn.state{isf};
39sn.state{isf} = state_a;
40
41options = self.getOptions;
42Solver.resetRandomGeneratorSeed(options.seed);
43
44self.result.('solver') = getName(self);
45% note: solver_nc_margaggr returns [Pr, G, lG, runtime]; the log-scale
46% normalizing constant is the THIRD output, not the second
47if isfield(self.result,'Prob') && isfield(self.result.Prob,'logNormConstAggr') && isfinite(self.result.Prob.logNormConstAggr)
48 [Pnir_vec,~,lG] = solver_nc_margaggr(sn, self.options, self.result.Prob.logNormConstAggr);
49else
50 [Pnir_vec,~,lG] = solver_nc_margaggr(sn, self.options);
51 self.result.Prob.logNormConstAggr = lG;
52end
53self.result.Prob.marginal = Pnir_vec;
54
55% solver_nc_margaggr already returns normalized probabilities
56% (it computes P = F_i * G(-i) / G which is properly normalized)
57% So we simply extract the probability for this station
58Pnir = Pnir_vec(ist);
59
60% Restore original state
61sn.state{isf} = original_state;
62
63runtime = toc(T0);
64self.result.runtime = runtime;
65
66end
Definition Station.m:245