LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
init_state_fcfs_nonexp.m
1clear node jobclass solver;
2
3model = Network('model');
4
5node{1} = Delay(model, 'Delay');
6node{2} = Queue(model, 'Queue1', SchedStrategy.FCFS);
7jobclass{1} = ClosedClass(model, 'Class1', 3, node{2}, 0);
8jobclass{2} = ClosedClass(model, 'Class2', 2, node{2}, 0);
9node{2}.setNumServers(3);
10
11node{1}.setService(jobclass{1}, Exp(1));
12node{1}.setService(jobclass{2}, Exp(1));
13node{2}.setService(jobclass{1}, Exp(1.2));
14node{2}.setService(jobclass{2}, Erlang.fitMeanAndSCV(1.0,0.5));
15
16M = model.getNumberOfStations();
17K = model.getNumberOfClasses();
18
19P = cell(K,K);
20P{1,1} = [0.3,0.1; 0.2,0];
21P{1,2} = [0.6,0; 0.8,0];
22P{2,2} = [0,1; 0,0];
23P{2,1} = [0,0; 1,0];
24
25model.link(P);
26[Qt,Ut,Tt] = model.getTranHandles();
27options = Solver.defaultOptions;
28options.verbose=1;
29options.samples=1e4;
30options.stiff=true;
31options.timespan = [0,5];
32%% This part illustrates the execution of different solvers
33solver{1} = CTMC(model,options);
34%solver{end+1} = JMT(model,options);
35%solver{end+1} = SSA(model,options);
36solver{end+1} = FLD(model,options);
37%solver{end+1} = MVA(model,options);
38dashing = {'-','--'};
39
40sn = model.getStruct();
41%%
42disp('Prior 1: prior all on default initialization')
43model.initDefault;
44disp('Initial state is:')
45[sn.space{1}(1,:),sn.space{2}(1,:)]
46for s=1:length(solver)
47 fprintf(1,'SOLVER: %s\n',solver{s}.getName());
48 [QNt,UNt,TNt] = solver{s}.getTranAvg(Qt,Ut,Tt);
49 subplot(3,1,1);
50 plot(QNt{2,1}.t,QNt{2,1}.metric,dashing{s}); hold on
51 solver{s}.reset();
52end
53title('Prior on default state');
54ylabel('QLen- station 2, class 1');
55ylim([0,5])
56xlabel('Time t');
57xlim(options.timespan)
58legend('ctmc','fluid')
59%%
60disp('Prior 2: prior all on first found state with the same number of jobs')
61model.initFromMarginal([0,0;4,1]);
62sn = model.getStruct;
63disp('Initial state is:')
64[sn.space{1}(1,:),sn.space{2}(1,:)]
65for s=1:length(solver)
66 solver{s}.reset();
67 fprintf(1,'SOLVER: %s\n',solver{s}.getName());
68 [QNt_marg,UNt_marg,TNt_marg] = solver{s}.getTranAvg(Qt,Ut,Tt);
69 subplot(3,1,2);
70 plot(QNt_marg{2,1}.t,QNt_marg{2,1}.metric,dashing{s}); hold on
71 solver{s}.reset();
72end
73title('Prior on first state with the same number of jobs');
74ylabel('QLen- station 2, class 1');
75ylim([0,5])
76xlabel('Time t');
77xlim(options.timespan)
78legend('ctmc','fluid')
79%%
80disp('Prior 3: uniform prior over all states with the same number of jobs')
81model.initFromMarginal([0,0;4,1]);
82disp('Initial states are:')
83space=sn.space;
84[repmat(space{1}(1,:),size(space{2},1),1),space{2}]
85prior = node{2}.getStatePrior;
86prior = 0*prior; prior=ones(size(prior))/length(prior);
87node{2}.setStatePrior(prior);
88for s=1:length(solver)
89 solver{s}.reset();
90 fprintf(1,'SOLVER: %s\n',solver{s}.getName());
91 [QNt_unif,UNt_unif,TNt_unif] = solver{s}.getTranAvg(Qt,Ut,Tt);
92 subplot(3,1,3);
93 plot(QNt_unif{2,1}.t,QNt_unif{2,1}.metric,dashing{s}); hold on
94end
95title('Uniform prior on states with the same number of jobs');
96ylabel('QLen- station 2, class 1');
97ylim([0,5])
98xlabel('Time t');
99xlim(options.timespan)
100legend('ctmc','fluid')
101hold off