1% Example 13: Open cluster
3% Source -> Dispatcher (Router) -> Server[1..M] -> Sink, with a single open
4%
class. Two equivalent ways to build the model are shown:
5% (a) the one-liner Network.clusterPs
static factory;
6% (b) the chainable Cluster builder, which also exposes helpers to
7% compare dispatching policies on the same cluster.
9%% Block 1: one-liner factory
10lambda = 0.4; % arrival rate of the open
class
11D = ones(3, 1); % mean service time = 1 at each of the 3 servers
12model = Network.clusterPs(lambda, D, RoutingStrategy.RAND);
14avgTable = MVA(model).getAvgTable()
16%% Block 2: Cluster builder with non-uniform multi-server queues
17cluster = Cluster().setNumStations(3).setArrivalRate(0.4).setServiceRate(1.0);
18cluster.setScheduling(SchedStrategy.FCFS);
19cluster.setStationCounts([2; 1; 1]); % Server1
is M/M/2, Server2/3 are M/M/1
20avgTableFcfs = MVA(cluster.build()).getAvgTable()
22%% Block 3: cross-check the same FCFS multi-server model under three simulators
23% JMT
is a Java-based discrete-
event simulator that uses an XML model file;
24% LDES
is the LINE Discrete Event Simulator built on the SSJ library and
25% invoked as a subprocess; SSA
is LINE
's native stochastic simulator
26% using the next-reaction method. All three produce statistically
27% equivalent results on this open-class cluster.
28fprintf('\n=== JMT ===\n
');
29disp(JMT(cluster.build(), 'seed
', 23000, 'samples
', 20000).getAvgTable());
30fprintf('=== LDES ===\n
');
31disp(LDES(cluster.build(), 'seed
', 23000, 'samples
', 20000).getAvgTable());
32fprintf('=== SSA ===\n
');
33disp(SSA(cluster.build(), 'seed
', 23000, 'samples
', 20000).getAvgTable());
35%% Block 4: compare dispatching policies via simulation
36% MVA assumes RAND (product-form). For non-product-form policies such as
37% RROBIN we drop to a simulator with a small sample budget.
38cluster2 = Cluster().setNumStations(3).setArrivalRate(0.4).setServiceRate(1.0);
39cluster2.setScheduling(SchedStrategy.PS);
40solverFcn = @(m) JMT(m, 'seed
', 23000, 'samples
', 5000).getAvgTable();
41results = cluster2.compareDispatching(solverFcn, ...
42 [RoutingStrategy.RAND, RoutingStrategy.RROBIN]);
46 fprintf('\n=== Dispatching: %s ===\n
', keys_{k});
47 disp(results(keys_{k}));