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% If this call is re-enabled, keep SolverMVA's own iter_tol (1e-6): the generic
38% Solver.defaultOptions value (1e-4) stops the AMVA fixed point early.
39%mvaOptions = options; mvaOptions.iter_tol = SolverMVA.defaultOptions.iter_tol;
40%solver{end+1} = MVA(model,mvaOptions);
41dashing = {'-','--'};
42
43sn = model.getStruct();
44%%
45disp('Prior 1: prior all on default initialization')
46model.initDefault;
47disp('Initial state is:')
48[sn.space{1}(1,:),sn.space{2}(1,:)]
49for s=1:length(solver)
50 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
51 [QNt,UNt,TNt] = solver{s}.getTranAvg(Qt,Ut,Tt);
52 fprintf('SteadyStateQLen[%s/Prior1]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt{2,1}.metric(end));
53 subplot(3,1,1);
54 plot(QNt{2,1}.t,QNt{2,1}.metric,dashing{s}); hold on
55 solver{s}.reset();
56end
57title('Prior on default state');
58ylabel('QLen- station 2, class 1');
59ylim([0,5])
60xlabel('Time t');
61xlim(options.timespan)
62legend('ctmc','fluid')
63%%
64disp('Prior 2: prior all on first found state with the same number of jobs')
65model.initFromMarginal([0,0;4,1]);
66sn = model.getStruct;
67disp('Initial state is:')
68[sn.space{1}(1,:),sn.space{2}(1,:)]
69for s=1:length(solver)
70 solver{s}.reset();
71 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
72 [QNt_marg,UNt_marg,TNt_marg] = solver{s}.getTranAvg(Qt,Ut,Tt);
73 fprintf('SteadyStateQLen[%s/Prior2]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt_marg{2,1}.metric(end));
74 subplot(3,1,2);
75 plot(QNt_marg{2,1}.t,QNt_marg{2,1}.metric,dashing{s}); hold on
76 solver{s}.reset();
77end
78title('Prior on first state with the same number of jobs');
79ylabel('QLen- station 2, class 1');
80ylim([0,5])
81xlabel('Time t');
82xlim(options.timespan)
83legend('ctmc','fluid')
84%%
85disp('Prior 3: uniform prior over all states with the same number of jobs')
86model.initFromMarginal([0,0;4,1]);
87disp('Initial states are:')
88space=sn.space;
89[repmat(space{1}(1,:),size(space{2},1),1),space{2}]
90prior = node{2}.getStatePrior;
91prior = 0*prior; prior=ones(size(prior))/length(prior);
92node{2}.setStatePrior(prior);
93for s=1:length(solver)
94 solver{s}.reset();
95 %fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
96 [QNt_unif,UNt_unif,TNt_unif] = solver{s}.getTranAvg(Qt,Ut,Tt);
97 fprintf('SteadyStateQLen[%s/Prior3]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt_unif{2,1}.metric(end));
98 subplot(3,1,3);
99 plot(QNt_unif{2,1}.t,QNt_unif{2,1}.metric,dashing{s}); hold on
100end
101title('Uniform prior on states with the same number of jobs');
102ylabel('QLen- station 2, class 1');
103ylim([0,5])
104xlabel('Time t');
105xlim(options.timespan)
106legend('ctmc','fluid')
107hold off
Definition Station.m:245