5#ifndef LINE_SOLVERS_LDES_LDES_SPN_H
6#define LINE_SOLVERS_LDES_LDES_SPN_H
62 std::function<double(
const std::vector<double>&)>
dep;
67 std::vector<std::tuple<std::size_t, std::size_t, double>>
exits;
86 for (std::size_t p = 0; p < m.
enabling.size() && p < tok.size(); ++p)
87 if (tok[p] < m.
enabling[p])
return false;
88 for (std::size_t p = 0; p < m.
inhibiting.size() && p < tok.size(); ++p)
98 const double g = m.
dep(tok);
99 r *= (g > 0.0) ? g : 0.0;
110 double degree = std::numeric_limits<double>::infinity();
111 for (std::size_t p = 0; p < m.
enabling.size() && p < tok.size(); ++p)
112 if (m.
enabling[p] > 0.0) degree = std::min(degree, std::floor(tok[p] / m.
enabling[p]));
113 if (!std::isfinite(degree))
return 1.0;
114 return std::min(m.
servers, degree);
119 for (std::size_t p = 0; p < m.
enabling.size() && p < tok.size(); ++p)
121 for (std::size_t p = 0; p < m.
firing.size() && p < tok.size(); ++p) tok[p] += m.
firing[p];
131 double best_prio = std::numeric_limits<double>::infinity();
133 if (m.immediate &&
spn_enabled(m, tok)) best_prio = std::min(best_prio, m.priority);
134 if (!std::isfinite(best_prio))
return -1;
137 if (m.immediate && m.priority == best_prio &&
spn_enabled(m, tok)) total += m.weight;
138 if (!(total > 0.0)) {
139 for (std::size_t k = 0; k < modes.size(); ++k)
140 if (modes[k].immediate && modes[k].priority == best_prio &&
spn_enabled(modes[k], tok))
141 return static_cast<int>(k);
145 const double x = u * total;
146 for (std::size_t k = 0; k < modes.size(); ++k)
147 if (modes[k].immediate && modes[k].priority == best_prio &&
spn_enabled(modes[k], tok)) {
148 acc += modes[k].weight;
149 if (x < acc)
return static_cast<int>(k);
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
double spn_rate(const SpnMode &m, const std::vector< double > &tok)
The rate of a timed mode under the current marking.
double spn_active_servers(const SpnMode &m, const std::vector< double > &tok)
The clocks an enabled timed mode runs at once: min(servers, enabling degree), the degree being the fl...
int spn_pick_immediate(const std::vector< SpnMode > &modes, const std::vector< double > &tok, double u)
Pick among the enabled IMMEDIATE modes: the highest priority first (lowest value),...
bool spn_enabled(const SpnMode &m, const std::vector< double > &tok)
True when m is enabled by the marking tok, which is indexed the same way as the mode's own vectors – ...
void spn_fire(const SpnMode &m, std::vector< double > &tok)
Move the tokens of one firing: consume the enabling counts, deposit the firing ones.
Conservation laws of a layered queueing network, enumerated from its structure.
One mode of a transition, resolved to what the event loop needs.
std::vector< double > enabling
per (place, class), tokens required
std::function< double(const std::vector< double > &)> dep
marking multiplier
std::vector< std::tuple< std::size_t, std::size_t, double > > exits
Output arcs to NODES THAT ARE NOT PLACES, (node, class, count): a Sink takes the token out of the net...
double rate
nominal firing rate of a timed mode
std::vector< double > inhibiting
per (place, class), tokens that block (inf = never)
std::vector< double > firing
per (place, class), tokens moved on a firing
std::vector< double > fired
per mode
std::vector< std::size_t > places
the place NODES its modes reference, in order
std::vector< SpnMode > modes