LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
tut10_dep_process_analysis.m
1% Example 9: Studying a departure process
2[model,source,queue,sink,oclass] = gallery_merl1;
3%% Block 4: solution
4% SCVdEst below is a Monte Carlo estimate off sampleSysAggr, so the seed is
5% part of the example: unseeded, it varied over ~0.889-0.920 across runs,
6% three times the 1e-2 tolerance its regression test asserts. Matches the
7% Python tut10_dep_process_analysis.py, which already pins seed=23000.
8solver = CTMC(model,'cutoff',150,'seed',23000);
9
10sa = solver.sampleSysAggr(5e3);
11ind = model.getNodeIndex(queue);
12
13filtEvent = cellfun(@(c) c.node == ind && (isequal(c.event, EventType.DEP) || (isnumeric(c.event) && c.event == 2)), sa.event);
14interDepTimes = diff(cellfun(@(c) c.t, {sa.event{filtEvent}}));
15
16% estimated squared coeff. of variation of departures
17SCVdEst = var(interDepTimes)/mean(interDepTimes)^2
18
19util = solver.getAvgUtil();
20util = util(queue);
21avgWaitTime = solver.getAvgWaitT(); % Waiting time excluding service
22avgWaitTime = avgWaitTime(queue);
23SCVa = source.getArrivalProcess(oclass).getSCV();
24svcRate = queue.getServiceProcess(oclass).getRate();
25SCVs = queue.getServiceProcess(oclass).getSCV();
26
27% Marshall's exact formula
28SCVd = SCVa + 2*util^2*SCVs - 2*util*(1-util)*svcRate*avgWaitTime
29
30% Calculate relative error between simulated and theoretical SCV
31relativeError = abs(SCVdEst - SCVd) / SCVd * 100;
32fprintf('\n=== Departure Process Analysis Results ===\n');
33fprintf('Simulated SCV of departures: %.6f\n', SCVdEst);
34fprintf('Theoretical SCV (Marshall): %.6f\n', SCVd);
35fprintf('Relative error: %.2f%%\n', relativeError);
Definition Station.m:245