5#ifndef LINE_SOLVERS_SSA_SSA_EVENT_CACHE_H
6#define LINE_SOLVERS_SSA_SSA_EVENT_CACHE_H
122 std::size_t cls,
bool no_promote =
false,
126 if (sn_ != 0 && sn_ != &
sn)
128 "SsaEventCache: queried with a different NetworkStruct from the one it was "
129 "created against. The memoized successors are a function of that struct's rates, "
130 "capacities and routing, so serving them here would answer about another model");
134 key.
event =
static_cast<int>(event);
138 key.
inspace.resize(inspace.size());
139 for (std::size_t j = 0; j < inspace.size(); ++j)
142 const typename std::map<SsaEventKey, qn::EventOutcome<T> >::const_iterator it =
144 if (it != memo_.end()) {
161 std::size_t
hits()
const {
return hits_; }
162 std::size_t
misses()
const {
return misses_; }
163 std::size_t
size()
const {
return memo_.size(); }
174 std::map<SsaEventKey, qn::EventOutcome<T> > memo_;
175 std::size_t hits_ = 0, misses_ = 0;
A network plus its refreshed NetworkStruct.
std::size_t hits() const
Hits and misses, so a caller can report the memo's effect.
qn::EventOutcome< T > after_event(const qn::NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &inspace, lang::EventType event, std::size_t cls, bool no_promote=false, const T &aux_rate=num_traits< T >::from_int(0))
State.afterEvent with the lookup in front of it.
static SsaEventCache create(bool enabled, const qn::NetworkStruct< T > &sn)
EventCache.create(enabled, sn).
std::size_t misses() const
SsaEventCache(bool enabled, const qn::NetworkStruct< T > *sn)
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
EventType
The events a state can undergo, with the values of MATLAB EventType.
EventOutcome< T > after_event(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &inspace, EventType event, std::size_t cls, bool no_promote=false, const T &aux_rate=num_traits< T >::from_int(0))
Port of State.afterEvent: the successors of one event at one NODE.
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
Port of the event half of MATLAB's +State package: the successor states an event produces at one node...
What one event produces at one node: the successor rows, their rates and their probabilities,...
The memoization key: the argument list of after_event, in fields.
int event
EventType, as its underlying value
std::vector< double > inspace
the node's local state row
std::size_t cls
1-based class index
bool operator<(const SsaEventKey &o) const
std::size_t ind
1-based node index