LINE Solver (C++)
Templated C++ port of the LINE queueing solver
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
24
25namespace line {
26namespace spn {
27
28struct 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
35template <class T>
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
A network plus its refreshed NetworkStruct.
SpnTraps spn_traps(const qn::NetworkStruct< T > &sn, const std::vector< double > &init=std::vector< double >())
Definition spn_traps.h:36
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
Shared net model of the Petri-net property functions (spn_tinvariants, spn_siphons,...
std::vector< long long > m0
Definition spn_traps.h:32
std::vector< bool > marked
trap i holds a token at m0
Definition spn_traps.h:31
std::vector< std::size_t > places
1-based node indices, in level order
Definition spn_traps.h:29
std::vector< std::vector< int > > Q
one minimal trap per row (0/1 over levels)
Definition spn_traps.h:30