LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
spn_queueing_place.m
1% Closed queueing Petri net (QPN) with two queueing places.
2%
3% A queueing place embeds a scheduling station inside a Petri-net place: an
4% arriving token is served by the place's embedded queue and, on completion,
5% moves to a depository from which the output transitions consume it.
6%
7% Here a CPU (single-server FCFS queueing place) and a think stage (infinite-
8% server queueing place) exchange a fixed population of N tokens through two
9% immediate transitions. This is the queueing-Petri-net rendering of a machine-
10% repairman / finite-population model, so its exact solution is available from
11% SolverMVA on the equivalent Delay+Queue network for cross-validation.
12
13N = 4;
14model = Network('QueueingPetriNet');
15
16% Two queueing places: setService turns each Place into a queueing place whose
17% embedded queue is served under the scheduling strategy of its constructor.
18cpu = Place(model, 'CPU', SchedStrategy.FCFS); % single-server embedded queue
19think = Place(model, 'Think', SchedStrategy.INF); % infinite-server embedded queue
20
21jobs = ClosedClass(model, 'Jobs', N, think, 0);
22cpu.setService(jobs, Exp(1.5)); % embedded FCFS service, rate 1.5
23think.setService(jobs, Exp(0.5)); % embedded think time, mean 2
24
25% Two immediate transitions cycle one token per firing between the places.
26toCPU = Transition(model, 'toCPU');
27m1 = toCPU.addMode('m1');
28toCPU.setTimingStrategy(m1, TimingStrategy.IMMEDIATE);
29toCPU.setEnablingConditions(m1, jobs, think, 1);
30toCPU.setFiringOutcome(m1, jobs, cpu, 1);
31
32toThink = Transition(model, 'toThink');
33m2 = toThink.addMode('m2');
34toThink.setTimingStrategy(m2, TimingStrategy.IMMEDIATE);
35toThink.setEnablingConditions(m2, jobs, cpu, 1);
36toThink.setFiringOutcome(m2, jobs, think, 1);
37
38P = model.initRoutingMatrix();
39P.set(jobs, jobs, think, toCPU, 1.0);
40P.set(jobs, jobs, toCPU, cpu, 1.0);
41P.set(jobs, jobs, cpu, toThink, 1.0);
42P.set(jobs, jobs, toThink, think, 1.0);
43model.link(P);
44
45% Initial marking: all tokens in the think place.
46think.setState(N);
47cpu.setState(0);
48
49% Queueing places are simulated by LDES.
50AvgTableLDES = SolverLDES(model, 'seed', 23000, 'samples', 2e5).avgTable()
51
52% Exact cross-check: the equivalent finite-population Delay + M/M/1 network.
53ref = Network('ref');
54delay = Delay(ref, 'Think');
55queue = Queue(ref, 'CPU', SchedStrategy.FCFS);
56cc = ClosedClass(ref, 'Jobs', N, delay, 0);
57delay.setService(cc, Exp(0.5));
58queue.setService(cc, Exp(1.5));
59ref.link(Network.serialRouting(delay, queue));
60AvgTableMVA = SolverMVA(ref).avgTable()
Definition Station.m:245