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% If this call is re-enabled, keep SolverMVA's own iter_tol (1e-6): the generic
33% Solver.defaultOptions value (1e-4) stops the AMVA fixed point early.
34%mvaOptions = options; mvaOptions.iter_tol = SolverMVA.defaultOptions.iter_tol;
35%solver{end+1} = MVA(model,mvaOptions);
36dashing = {'-','+'};
37
38%%
39model.initDefault;
40disp('Prior 1: prior all on default initialization')
41disp('Initial state is:')
42state=model.getState();
43[state{1}(1,:),state{2}(1,:)]
44for s=1:length(solver)
45 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
46 [QNt,UNt,TNt] = solver{s}.getTranAvg(Qt,Ut,Tt);
47 fprintf('SteadyStateQLen[%s/Prior1]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt{2,1}.metric(end));
48 subplot(1,2,1);
49 plot(QNt{2,1}.t,QNt{2,1}.metric,dashing{s}); hold on
50 solver{s}.reset();
51end
52title('Prior on default state');
53ylabel('Queue length - station 2, class 1');
54ylim([3,5])
55xlabel('Time t');
56xlim(options.timespan)
57legend('ctmc','fluid','Location','SouthEast')
58
59%%
60model.initFromMarginal([2;3]);
61disp('Prior 2: prior all on first found state with given marginal')
62disp('Initial state is:')
63state=model.getState();
64[state{1}(1,:),state{2}(1,:)]
65for s=1:length(solver)
66 solver{s}.reset();
67 fprintf(1,'SOLVER: %s\n',strrep(solver{s}.getName(),'Solver',''));
68 [QNt_marg,UNt_marg,TNt_marg] = solver{s}.getTranAvg(Qt,Ut,Tt);
69 fprintf('SteadyStateQLen[%s/Prior2]: %.6f\n', strrep(solver{s}.getName(),'Solver',''), QNt_marg{2,1}.metric(end));
70 subplot(1,2,2);
71 plot(QNt_marg{2,1}.t,QNt_marg{2,1}.metric,dashing{s}); hold on
72 solver{s}.reset();
73end
74title('Prior on state with 3 jobs in station 2');
75ylabel('Queue length - station 2, class 1');
76ylim([3,5])
77xlabel('Time t');
78xlim(options.timespan)
79%legend('ctmc','fluid')
Definition Station.m:245