1function Prob = getProb(self, node, state)
2% PROB = GETPROB(NODE, STATE) Returns state probability estimated via DES simulation
4% @brief Estimates steady-state marginal state probabilities at a node via DES simulation
6% This method estimates state probabilities by running a discrete-
event simulation
7% and computing the fraction of total simulation time spent in each state.
9% @param self SolverDES instance
10% @param node Queue or node object (or node index as integer)
11% @param state (optional) State specification as vector. If provided, returns
12% probability of
this specific state. If omitted, uses current network state.
14% @
return Prob Estimated state probability value
15% - 0
if state not seen during simulation (rare event)
17% @note DES estimates probabilities from finite simulation. Accuracy improves with
18% more samples. If the specified state
is not observed during simulation,
19% probability 0
is returned.
21% @warning Simulation-based estimate - results vary between runs unless seed
is set.
22% Use
'seed' option in constructor
for reproducible results.
24% @see getProbAggr - Returns state probabilities aggregated over phases
25% @see getProbSys - Returns joint system state probabilities
29% solver = SolverDES(model,
'samples', 50000,
'seed', 42);
30% queue1 = model.nodes{1};
32% % Estimate probability of state [2 jobs of
class 0, 1 of class 1]
33% prob_state = solver.getProb(queue1, [2, 1]);
34% fprintf(
'Estimated Pr[state=[2,1]] = %.4f\n', prob_state);
37if GlobalConstants.DummyMode
42% Convert model to Java
43jmodel = LINE2JLINE(self.model);
45% Create Java DES options
46joptions = jline.solvers.des.DESOptions();
47joptions.samples = self.options.samples;
48joptions.seed = self.options.seed;
51jsolver = jline.solvers.des.SolverDES(jmodel, joptions);
53% Get stateful node from model
54sn = self.model.getStruct;
61% Find the corresponding Java node
62statefulNodes = jmodel.getStatefulNodes();
63isf = sn.nodeToStateful(nodeIdx);
64jnode = statefulNodes.get(isf - 1); % Java
is 0-indexed
66% Convert state to Java Matrix if provided
67if nargin < 3 || isempty(state)
70 jstate = JLINE.to_jline_matrix(state(:)');
73% Call Java getProb method and extract probability value
75 jresult = jsolver.getProb(jnode);
77 jresult = jsolver.getProb(jnode, jstate);
80% Extract the probability value from the ProbabilityResult
object
81Prob = jresult.probability;