LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
statepr_allprobs_fcfs.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.FCFS);
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(3));
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=1e5;
42options.seed = 23000;
43
44% set a custom initial state
45n=[ 0,0;
46 1,0;
47 0,1];
48
49for i=1:M
50 node{i}.setState(n(i,:));
51end
52state = model.getState;
53
54%% getProbAggr
55solver = CTMC(model,options);
56Pr = solver.getProbAggr(node{M});
57fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
58Pmarga_ctmc = Pr
59
60solver = NC(model,options);
61Pr = solver.getProbAggr(node{M});
62fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
63Pmarga_nc = Pr
64
65solver = SSA(model,options);
66Pr = solver.getProbAggr(node{M});
67fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
68Pmarga_ssa = Pr
69
70solver = JMT(model,options);
71Pr = solver.getProbAggr(node{M});
72fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
73Pmarga_jmt = Pr
74
75%% getProb
76solver = CTMC(model,options);
77Pr = solver.getProb(node{M});
78fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
79Pmarg_ctmc = Pr
80
81% solver = NC(model,options);
82% Pr = solver.getProb(node{M});
83% Pjoint_nc = Pr
84
85solver = SSA(model,options);
86Pr = solver.getProb(node{M});
87fprintf(1,'Station %d is in state %s with probability %d\n',i,mat2str(state{i}),Pr);
88Pmarg_ssa = Pr
89
90%% getProbSysAggr
91solver = CTMC(model,options);
92Pr = solver.getProbSysAggr();
93Pjointa_ctmc = Pr
94
95solver = NC(model,options);
96Pr = solver.getProbSysAggr();
97Pjointa_nc = Pr
98
99solver = SSA(model,options);
100Pr = solver.getProbSysAggr();
101Pjointa_ssa = Pr
102
103solver = JMT(model,options);
104Pr = solver.getProbSysAggr();
105Pjointa_jmt = Pr
106
107%% getProbSys
108solver = CTMC(model,options);
109Pr = solver.getProbSys();
110Pjoint_ctmc = Pr
111
112%solver = NC(model,options);
113%Pr = solver.getProbSys();
114%Pjoint_nc = Pr
115
116solver = SSA(model,options);
117Pr = solver.getProbSys();
118Pjoint_ssa = Pr
119
120% options.samples = 3e5;
121% solver = JMT(model,options);
122% Pr = solver.getProbSys();
123% Pjoint_jmt = Pr
124