LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
statepr_allprobs_ps.m
1clear node jobclass
2
3model = Network('model');
4
5node{1} = Delay(model, 'Delay');
6node{2} = Queue(model, 'Queue1', SchedStrategy.PS);
7node{3} = Queue(model, 'Queue2', SchedStrategy.PS);
8node{3}.setNumServers(2);
9
10N=[2,0];
11jobclass{1} = ClosedClass(model, 'Class1', N(1), node{1}, 0);
12jobclass{2} = ClosedClass(model, 'Class2', N(2), node{1}, 0);
13
14node{1}.setService(jobclass{1}, Exp(1));
15node{1}.setService(jobclass{2}, Exp(1));
16
17node{2}.setService(jobclass{1}, Exp(3));
18node{2}.setService(jobclass{2}, Exp(4));
19
20node{3}.setService(jobclass{1}, Exp(1));
21node{3}.setService(jobclass{2}, Exp(3));
22
23K = length(jobclass);
24P = model.initRoutingMatrix;
25
26P{1,1} = [0,1,0; 0,0,0; 1,0,0];
27P{1,2} = [0,0,0; 0,0,1; 0,0,0];
28P{2,1} = [0,1,0; 0,0,0; 1,0,0];
29P{2,2} = [0,0,0; 0,0,1; 0,0,0];
30
31model.link(P);
32
33M = model.getNumberOfStations();
34K = model.getNumberOfClasses();
35
36%This part illustrates the execution of different solvers
37fprintf(1,'This example illustrates the calculation of probabilities via normalizing constants.\n')
38
39options = Solver.defaultOptions;
40options.verbose=1;
41options.samples=2e4;
42options.seed = 23000;
43% set a custom initial state
44n=[ 0,0;
45 1,0;
46 0,1];
47
48for i=1:M
49 node{i}.setState(n(i,:));
50end
51state = model.getState;
52
53%% getProbAggr
54% marginal probabilities for the aggregated state space where station i
55% is specified by a tuple (nir), r=1,...R, R being the number of classes.
56solver = CTMC(model,options);
57Pr = solver.getProbAggr(node{M});
58fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
59Pmarga_ctmc = Pr
60
61solver = NC(model,options);
62Pr = solver.getProbAggr(node{M});
63fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
64Pmarga_nc = Pr
65
66solver = SSA(model,options);
67Pr = solver.getProbAggr(node{M});
68fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
69Pmarga_ssa = Pr
70
71solver = JMT(model,options);
72Pr = solver.getProbAggr(node{M});
73fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
74Pmarga_jmt = Pr
75
76%% getProb
77% marginal probabilities for the detailed state space, which tracks also
78% the phases of service
79solver = CTMC(model,options);
80Pr = solver.getProb(node{M});
81fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
82Pmarg_ctmc = Pr
83
84% solver = NC(model,options);
85% Pr = solver.getProb(node{M});
86% Pmarg_nc = Pr
87
88solver = SSA(model,options);
89Pr = solver.getProb(node{M});
90fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
91Pmarg_ssa = Pr
92
93%% getProbSysAggr
94% joint state probabilities for the aggregated state space where station i
95% is specified by a tuple (nir), r=1,...R, R being the number of classes.
96solver = CTMC(model,options);
97Pr = solver.getProbSysAggr();
98Pjointa_ctmc = Pr
99
100solver = NC(model,options);
101Pr = solver.getProbSysAggr();
102Pjointa_nc = Pr
103
104solver = SSA(model,options);
105Pr = solver.getProbSysAggr();
106Pjointa_ssa = Pr
107
108solver = JMT(model,options);
109Pr = solver.getProbSysAggr();
110Pjointa_jmt = Pr
111
112%% getProbSys
113% joint state probabilities for the detailed state space, which tracks also
114% the phases of service
115solver = CTMC(model,options);
116Pr = solver.getProbSys();
117Pjoint_ctmc = Pr
118
119% solver = NC(model,options);
120% Pr = solver.getProbSys();
121% Pjoint_nc = Pr
122
123solver = SSA(model,options);
124Pr = solver.getProbSys();
125Pjoint_ssa = Pr
126
127% options.samples = 3e5;
128% solver = JMT(model,options);
129% Pr = solver.getProbSys();
130% Pjoint_jmt = Pr
131