1function Pnir = getProbAggr(self, node, state_a)
2% PNIR = GETPROBAGGR(NODE, STATE_A)
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.
7% Compare with getProbMarg: returns total queue-length distribution,
8% i.e.,
P(n total jobs) summed over all class combinations.
11% node - Queue or node
object
12% state_a - Per-class job counts, e.g., [2,1] = 2 class-1, 1 class-2
15% Pnir - Scalar probability in [0,1]
17if GlobalConstants.DummyMode
23sn = self.model.getStruct(true); % sync node states into sn.state
25% Get unnormalized probability using original NC method
26ist = sn.nodeToStation(node.index);
27isf = sn.nodeToStateful(node.index);
29 state_a = sn.state{isf};
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);
37% Store original state and set requested state
38original_state = sn.state{isf};
39sn.state{isf} = state_a;
41options = self.getOptions;
42Solver.resetRandomGeneratorSeed(options.seed);
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);
50 [Pnir_vec,~,lG] = solver_nc_margaggr(sn, self.options);
51 self.result.Prob.logNormConstAggr = lG;
53self.result.Prob.marginal = Pnir_vec;
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
60% Restore original state
61sn.state{isf} = original_state;
64self.result.runtime = runtime;