LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
init_state_fcfs_exp.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', 5, node{2}, 0);
8
9node{1}.setService(jobclass{1}, Exp(1));
10node{2}.setService(jobclass{1}, Exp(0.7));
11
12M = model.getNumberOfStations();
13K = model.getNumberOfClasses();
14
15P = cell(K,K);
16P{1} = circul(2);
17
18model.link(P);
19[Qt,Ut,Tt] = model.getTranHandles();
20options = Solver.defaultOptions;
21options.verbose=0;
22options.samples=1e4;
23options.stiff=true;
24options.timespan = [0,40];
25
26%% This part illustrates the execution of different solvers
27solver={};
28solver{end+1} = CTMC(model,options);
29%solver{end+1} = JMT(model,options);
30%solver{end+1} = SSA(model,options);
31solver{end+1} = FLD(model,options);
32%solver{end+1} = MVA(model,options);
33dashing = {'-','+'};
34
35%%
36model.initDefault;
37disp('Prior 1: prior all on default initialization')
38disp('Initial state is:')
39state=model.getState();
40[state{1}(1,:),state{2}(1,:)]
41for s=1:length(solver)
42 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
43 [QNt,UNt,TNt] = solver{s}.getTranAvg(Qt,Ut,Tt);
44 fprintf('SteadyStateQLen[%s/Prior1]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt{2,1}.metric(end));
45 subplot(1,2,1);
46 plot(QNt{2,1}.t,QNt{2,1}.metric,dashing{s}); hold on
47 solver{s}.reset();
48end
49title('Prior on default state');
50ylabel('Queue length - station 2, class 1');
51ylim([3,5])
52xlabel('Time t');
53xlim(options.timespan)
54legend('ctmc','fluid','Location','SouthEast')
55
56%%
57model.initFromMarginal([2;3]);
58disp('Prior 2: prior all on first found state with given marginal')
59disp('Initial state is:')
60state=model.getState();
61[state{1}(1,:),state{2}(1,:)]
62for s=1:length(solver)
63 solver{s}.reset();
64 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
65 [QNt_marg,UNt_marg,TNt_marg] = solver{s}.getTranAvg(Qt,Ut,Tt);
66 fprintf('SteadyStateQLen[%s/Prior2]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt_marg{2,1}.metric(end));
67 subplot(1,2,2);
68 plot(QNt_marg{2,1}.t,QNt_marg{2,1}.metric,dashing{s}); hold on
69 solver{s}.reset();
70end
71title('Prior on state with 3 jobs in station 2');
72ylabel('Queue length - station 2, class 1');
73ylim([3,5])
74xlabel('Time t');
75xlim(options.timespan)
76%legend('ctmc','fluid')