LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
matlab
examples
basic
stochPetriNet
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
13
N = 4;
14
model = 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.
18
cpu = Place(model, '
CPU
', SchedStrategy.FCFS); % single-server embedded queue
19
think = Place(model, '
Think
', SchedStrategy.INF); % infinite-server embedded queue
20
21
jobs = ClosedClass(model, '
Jobs
', N, think, 0);
22
cpu.setService(jobs, Exp(1.5)); % embedded FCFS service, rate 1.5
23
think.setService(jobs, Exp(0.5)); % embedded think time, mean 2
24
25
% Two immediate transitions cycle one token per firing between the places.
26
toCPU = Transition(model, '
toCPU
');
27
m1 = toCPU.addMode('
m1
');
28
toCPU.setTimingStrategy(m1, TimingStrategy.IMMEDIATE);
29
toCPU.setEnablingConditions(m1, jobs, think, 1);
30
toCPU.setFiringOutcome(m1, jobs, cpu, 1);
31
32
toThink = Transition(model, '
toThink
');
33
m2 = toThink.addMode('
m2
');
34
toThink.setTimingStrategy(m2, TimingStrategy.IMMEDIATE);
35
toThink.setEnablingConditions(m2, jobs, cpu, 1);
36
toThink.setFiringOutcome(m2, jobs, think, 1);
37
38
P = model.initRoutingMatrix();
39
P.set(jobs, jobs, think, toCPU, 1.0);
40
P.set(jobs, jobs, toCPU, cpu, 1.0);
41
P.set(jobs, jobs, cpu, toThink, 1.0);
42
P.set(jobs, jobs, toThink, think, 1.0);
43
model.link(P);
44
45
% Initial marking: all tokens in the think place.
46
think.setState(N);
47
cpu.setState(0);
48
49
% Queueing places are simulated by LDES.
50
AvgTableLDES = SolverLDES(model, '
seed
', 23000, '
samples
', 2e5).avgTable()
51
52
% Exact cross-check: the equivalent finite-population Delay + M/M/1 network.
53
ref = Network('
ref
');
54
delay = Delay(ref, '
Think
');
55
queue = Queue(ref, '
CPU
', SchedStrategy.FCFS);
56
cc = ClosedClass(ref, '
Jobs
', N, delay, 0);
57
delay.setService(cc, Exp(0.5));
58
queue.setService(cc, Exp(1.5));
59
ref.link(Network.serialRouting(delay, queue));
60
AvgTableMVA = SolverMVA(ref).avgTable()
is
Definition
qsys_mg1_prio.m:10
the
Definition
Station.m:245
Generated by
1.9.8