LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
spn_traps.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_API_SPN_SPN_TRAPS_H
6
#define LINE_API_SPN_SPN_TRAPS_H
7
8
/**
9
* @file
10
* @ingroup api_spn
11
* All minimal traps of a stochastic Petri net (Murata 1989, sec. VI-A). A
12
* trap Q has Q* contained in *Q: once marked it stays marked. Traps are the
13
* siphons of the reverse net, so the enumeration and its worst-case
14
* exponential cost are those of spn_siphons with Pre and Post swapped.
15
* marked(i) is true when trap i holds a token at m0. The check is
16
* structural: inhibitor arcs, priorities and the timed/immediate split are
17
* ignored. MATLAB twin: matlab/src/api/spn/spn_traps.m.
18
*/
19
20
#include <cstddef>
21
#include <vector>
22
23
#include "
line/api/spn/spn_net.h
"
24
25
namespace
line
{
26
namespace
spn
{
27
28
struct
SpnTraps
{
29
std::vector<std::size_t>
places
;
///< 1-based node indices, in level order
30
std::vector<std::vector<int>>
Q
;
///< one minimal trap per row (0/1 over levels)
31
std::vector<bool>
marked
;
///< trap i holds a token at m0
32
std::vector<long long>
m0
;
33
};
34
35
template
<
class
T>
36
SpnTraps
spn_traps
(
const
qn::NetworkStruct<T>
&
sn
,
37
const
std::vector<double>& init = std::vector<double>()) {
38
const
detail::SpnNet net = detail::spn_build_net(
sn
,
"spn_traps"
);
39
SpnTraps
out;
40
out.
places
= net.places;
41
out.
m0
= detail::spn_initmarking(
sn
, net, init,
"spn_traps"
);
42
const
std::vector<std::vector<bool>> L = detail::spn_minsiphons(net.post, net.pre);
43
out.
Q
= detail::spn_sets_to_int(L);
44
out.
marked
.assign(L.size(),
false
);
45
for
(std::size_t i = 0; i < L.size(); ++i)
46
for
(std::size_t l = 0; l < net.n; ++l)
47
if
(L[i][l] && out.
m0
[l] > 0) out.
marked
[i] =
true
;
48
return
out;
49
}
50
51
}
// namespace spn
52
}
// namespace line
53
54
#endif
// LINE_API_SPN_SPN_TRAPS_H
line::qn::NetworkStruct
A network plus its refreshed NetworkStruct.
Definition
network_struct.h:1070
line::sn
Definition
sn_arvr_state_dependent_balance.h:25
line::spn
Definition
spn_conv.h:57
line::spn::spn_traps
SpnTraps spn_traps(const qn::NetworkStruct< T > &sn, const std::vector< double > &init=std::vector< double >())
Definition
spn_traps.h:36
line
Conservation laws of a layered queueing network, enumerated from its structure.
Definition
aoi_dist2ph.h:52
spn_net.h
Shared net model of the Petri-net property functions (spn_tinvariants, spn_siphons,...
line::spn::SpnTraps
Definition
spn_traps.h:28
line::spn::SpnTraps::m0
std::vector< long long > m0
Definition
spn_traps.h:32
line::spn::SpnTraps::marked
std::vector< bool > marked
trap i holds a token at m0
Definition
spn_traps.h:31
line::spn::SpnTraps::places
std::vector< std::size_t > places
1-based node indices, in level order
Definition
spn_traps.h:29
line::spn::SpnTraps::Q
std::vector< std::vector< int > > Q
one minimal trap per row (0/1 over levels)
Definition
spn_traps.h:30
include
line
api
spn
spn_traps.h
Generated by
1.18.0