LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
tut09_dep_process_analysis.m
1% Example 9: Studying a departure process
2[model,source,queue,sink,oclass] = gallery_merl1;
3%% Block 4: solution
4solver = CTMC(model,'cutoff',150);
5
6sa = solver.sampleSysAggr(5e3);
7ind = model.getNodeIndex(queue);
8
9filtEvent = cellfun(@(c) c.node == ind && (isequal(c.event, EventType.DEP) || (isnumeric(c.event) && c.event == 2)), sa.event);
10interDepTimes = diff(cellfun(@(c) c.t, {sa.event{filtEvent}}));
11
12% estimated squared coeff. of variation of departures
13SCVdEst = var(interDepTimes)/mean(interDepTimes)^2
14
15util = solver.getAvgUtil();
16util = util(queue);
17avgWaitTime = solver.getAvgWaitT(); % Waiting time excluding service
18avgWaitTime = avgWaitTime(queue);
19SCVa = source.getArrivalProcess(oclass).getSCV();
20svcRate = queue.getServiceProcess(oclass).getRate();
21SCVs = queue.getServiceProcess(oclass).getSCV();
22
23% Marshall's exact formula
24SCVd = SCVa + 2*util^2*SCVs - 2*util*(1-util)*svcRate*avgWaitTime
25
26% Calculate relative error between simulated and theoretical SCV
27relativeError = abs(SCVdEst - SCVd) / SCVd * 100;
28fprintf('\n=== Departure Process Analysis Results ===\n');
29fprintf('Simulated SCV of departures: %.6f\n', SCVdEst);
30fprintf('Theoretical SCV (Marshall): %.6f\n', SCVd);
31fprintf('Relative error: %.2f%%\n', relativeError);