5#ifndef LINE_API_MC_CTMC_SSG_H
6#define LINE_API_MC_CTMC_SSG_H
76 std::vector<qn::NetState<T>>
space;
85 const std::size_t S =
sn.nof_stateful();
89 std::vector<std::map<std::vector<T>, std::size_t>> seen(S);
90 std::vector<std::vector<std::vector<T>>> rows(S);
92 std::size_t width = 0;
93 for (std::size_t st = 0; st < space.size(); ++st) {
95 for (std::size_t f = 0; f < S && f < space[st].local.size(); ++f) {
96 const std::vector<T>& loc = space[st].local[f];
98 typename std::map<std::vector<T>, std::size_t>::const_iterator it = seen[f].find(loc);
99 if (it == seen[f].end()) {
100 rows[f].push_back(loc);
101 seen[f][loc] = rows[f].size();
107 if (w > width) width = w;
110 for (std::size_t f = 0; f < S; ++f) {
111 const std::size_t nr = rows[f].size();
113 for (std::size_t a = 0; a < nr; ++a)
nc = std::max(
nc, rows[f][a].size());
115 for (std::size_t a = 0; a < nr; ++a)
116 for (std::size_t b = 0; b < rows[f][a].size(); ++b)
122 for (std::size_t st = 0; st < space.size(); ++st) {
124 for (std::size_t f = 0; f < space[st].local.size(); ++f)
125 for (std::size_t b = 0; b < space[st].local[f].size(); ++b)
126 out.
state_space(st, col++) = space[st].local[f][b];
131 out.
space = std::move(space);
137 if (cutoff.size() == R)
return cutoff;
138 if (cutoff.empty())
return std::vector<std::size_t>(R, 0);
139 if (cutoff.size() == 1)
return std::vector<std::size_t>(R, cutoff[0]);
140 throw InputError(
"ctmc_ssg: options.cutoff must hold one entry per class");
159 "ctmc_ssg: Fork-join models require reachability-based state space generation "
160 "(options.config.state_space_gen='reachable').");
161 const std::vector<std::size_t> cutoff =
163 std::vector<qn::NetState<T>> space =
182 if (!ctmc::analyzer_detail::default_init_state(
sn, init))
184 "ctmc_ssg_reachability: the model's initial marking admits no state; check the Place "
185 "populations against the class reference stations");
186 const std::vector<std::size_t> cutoff =
191 sn, init, sync, gsync, options.state_max, fjsync, cutoff, options.cutoff_mat);
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
The exception types the port throws.
Dense matrix and non-owning view.
Matrix< T > ctmc_state_space_aggr(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space)
Port of StateSpaceAggr: the per-(station, class) job counts of every state, as an (nstates x nstation...
std::vector< NetState< T > > reachable_space_generator(const NetworkStruct< T > &sn, const NetState< T > &init, const std::vector< Sync< T > > &sync, const std::vector< qn::GlobalSync< T > > &gsync=std::vector< qn::GlobalSync< T > >(), std::size_t maxst=3000000, const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >(), const std::vector< std::size_t > &cutoff=std::vector< std::size_t >(), const std::vector< std::vector< std::size_t > > &cutoff_mat=std::vector< std::vector< std::size_t > >())
Port of State.reachableSpaceGenerator: the states reachable from init.
CtmcSsgResult< T > assemble(const qn::NetworkStruct< T > &sn, std::vector< qn::NetState< T > > space)
The three matrix views from an enumerated space.
std::vector< std::size_t > cutoff_or_closed(const std::vector< std::size_t > &cutoff, std::size_t R)
CtmcSsgResult< T > ctmc_ssg_reachability(const qn::NetworkStruct< T > &sn, const CtmcSsgOptions &options=CtmcSsgOptions(), const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >())
Port of ctmc_ssg_reachability: the REACHABLE state space, walked from the model's initial state over ...
CtmcSsgResult< T > ctmc_ssg(const qn::NetworkStruct< T > &sn, const CtmcSsgOptions &options=CtmcSsgOptions(), const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >())
Port of ctmc_ssg: the FULL state space of the network.
std::vector< NetState< T > > space_generator(const NetworkStruct< T > &sn, const std::vector< std::size_t > &cutoff, std::size_t maxst=3000000, const std::vector< std::vector< std::size_t > > &cutoff_mat=std::vector< std::vector< std::size_t > >())
Port of State.spaceGenerator: every network state, reachable or not.
std::vector< Sync< T > > refresh_sync(const NetworkStruct< T > &sn, const std::vector< std::vector< bool > > &impatience_classes=std::vector< std::vector< bool > >(), const std::vector< std::size_t > &breakdown_nodes=std::vector< std::size_t >())
Port of MNetwork.refreshSync: the synchronization list.
std::vector< GlobalSync< T > > refresh_global_sync(const NetworkStruct< T > &sn)
Port of MNetwork.refreshGlobalSync: the ENABLE and FIRE synchronizations.
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 solver_ctmc.m: the infinitesimal generator of a queueing network, assembled from the enumerat...
Port of solver_ctmc_analyzer.m and the parts of @@SolverCTMC/runAnalyzer.m that surround one solve: t...
Port of the MATLAB +State package: the encoding that turns a station's state row into marginal job co...
Port of the event half of MATLAB's +State package: the successor states an event produces at one node...
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
The reference's options read here: options.cutoff and the state cap.
std::vector< std::size_t > cutoff
Per-class population bound for the open classes (options.cutoff); 0 = closed.
std::vector< std::vector< std::size_t > > cutoff_mat
Optional (nstations x nclasses) bound, the reference's matrix options.cutoff.
std::size_t state_max
Refuse beyond this many states (the reference's ctmc_max_states).
The reference's [stateSpace, stateSpaceAggr, stateSpaceHashed, nodeStateSpace].
Matrix< T > state_space_aggr
std::vector< qn::NetState< T > > space
The enumerated states as the solvers consume them (port-only convenience).
std::vector< Matrix< T > > node_state_space
One local space per stateful node, rows in first-seen order.
std::vector< std::vector< std::size_t > > state_space_hashed
1-based row of node_state_space[isf] each state occupies at node isf.
One fork firing synchronization: sn.fjsync{k}.
One network state: the per-stateful-node local rows it is composed of.