5#ifndef LINE_IO_LQN2PN_H
6#define LINE_IO_LQN2PN_H
101 std::vector<Lqn2PnCell>
run;
138 typedef std::pair<std::size_t, std::size_t> Key;
140 Lqn2Pn(
const lqn::LqnStruct<T>&
lsn,
const std::set<Key>& replies,
const std::string& replication,
141 const std::string& name, std::vector<std::string>* warnings,
Lqn2PnMap* map)
142 : l_(
lsn), replies_(replies), replication_(replication), name_(name), warnings_(warnings),
146 if (replication_ !=
"auto" && replication_ !=
"materialize" && replication_ !=
"pool")
148 "LQN2PN: replication must be 'auto', 'materialize' or 'pool'.");
156 static constexpr std::size_t NOPL =
static_cast<std::size_t
>(-1);
157 static constexpr std::size_t SINK =
static_cast<std::size_t
>(-2);
158 static constexpr std::size_t MAXCALLSTAGES = 20;
159 static constexpr std::size_t MAXREPLINSTANCES = 128;
173 std::size_t place, cls;
175 Arc(std::size_t p, std::size_t c,
double k = 1.0) : place(p), cls(c), n(k) {}
179 std::vector<Arc> ins, outs, inh;
189 std::vector<Mode> modes;
193 std::vector<Arc> outs;
196 std::size_t cls, free, busy;
200 std::size_t place, cls;
215 std::size_t aidx, place, cls;
219 std::size_t j, owner;
220 std::vector<JoinIn> inputs;
225 std::size_t eidx, trep, tok, ret, tidx;
230 std::vector<std::size_t> localActs;
231 std::map<std::pair<std::size_t, int>, std::size_t> visited;
232 std::vector<JoinRec> joins;
233 std::vector<std::size_t> forkStack;
235 std::vector<std::pair<T, std::size_t> > fwd;
238 std::vector<std::pair<std::string, std::vector<std::pair<std::size_t, std::size_t> > > > rows;
239 std::map<std::string, std::size_t> at;
240 void add(
const std::string& k, std::size_t p, std::size_t c) {
241 std::map<std::string, std::size_t>::iterator it = at.find(k);
242 if (it == at.end()) {
244 rows.push_back(std::make_pair(k, std::vector<std::pair<std::size_t, std::size_t> >()));
245 rows.back().second.push_back(std::make_pair(p, c));
247 rows[it->second].second.push_back(std::make_pair(p, c));
253 const std::set<Key>& replies_;
254 std::string replication_;
256 std::vector<std::string>* warnings_;
259 std::vector<double> replRaw_;
260 bool materialize_ =
false;
261 std::vector<std::size_t> refTasks_, openEntries_;
263 std::vector<PlaceRec> places_;
264 std::vector<std::size_t> uf_;
265 std::vector<ClassRec> classes_;
266 std::vector<TransRec> trans_;
267 std::vector<Marking> marking_;
268 std::map<std::string, int> usedNode_, usedClass_;
270 std::map<Key, Res> cpu_;
271 std::map<Key, std::vector<std::pair<std::size_t, std::size_t> > > psPos_, runPos_;
272 std::map<Key, std::vector<std::size_t> > psModes_;
273 std::vector<std::pair<Key, Res> > thr_;
274 std::map<Key, std::size_t> thrIdx_;
275 std::map<Key, std::size_t> ph2cls_;
276 Ordered actMap_, entryMap_;
277 std::vector<Key> entryStack_;
278 std::vector<std::pair<Key, std::size_t> > thinkPlace_;
279 std::vector<std::pair<std::size_t, std::size_t> > openSrc_;
293 void warn(
const std::string& msg) {
294 if (warnings_ !=
nullptr)
295 warnings_->push_back(
"LQN2PN: " + msg);
297 std::cerr <<
"[LINE] Warning: LQN2PN: " << msg << std::endl;
300 [[noreturn]]
static void refuse(
const std::string& kind,
const std::string& msg) {
304 static std::string fmtG(
double v) {
306 std::snprintf(buf,
sizeof(buf),
"%g", v);
307 return std::string(buf);
313 for (std::size_t i = 0; i < out.size(); ++i)
314 out[i] =
static_cast<char>(std::toupper(
static_cast<unsigned char>(out[i])));
321 const std::string& nm(std::size_t idx)
const {
return l_.
names[idx]; }
322 std::size_t parent(std::size_t idx)
const {
return l_.
parent[idx]; }
324 double mult(std::size_t idx)
const {
return l_.
mult[idx]; }
325 double imult(std::size_t idx)
const {
return std::trunc(l_.
mult[idx]); }
327 bool isAndJoinPre(std::size_t aidx)
const {
330 bool isAndFork(
const std::vector<std::size_t>& succ)
const {
331 if (succ.size() < 2)
return false;
332 for (std::size_t s : succ)
338 std::size_t countAndJoinBranches(std::size_t j)
const {
340 for (std::size_t p : l_.
graph.pred(j))
341 if (p != j && isAndJoinPre(p)) ++n;
345 static std::string suffixed(
const std::string& name, std::size_t rep) {
346 return rep == 0 ? name : name +
"_r" + std::to_string(rep + 1);
349 static std::string unique(std::map<std::string, int>& used,
const std::string& base) {
350 const int n = ++used[base];
351 return n == 1 ? base : base +
"_d" + std::to_string(n);
360 refuse(
"CacheTask",
"cache task " + nm(t) +
" has no Petri net image.");
362 refuse(
"SetupTask",
"setup or function task " + nm(t) +
" is not represented.");
364 for (std::size_t i = 0; i < l.
lincon_A.size(); ++i)
365 if (l.
lincon_A[i].rows() > 0) refuse(
"AdmissionConstraint",
"admission constraints are not represented.");
367 for (std::size_t i = 0; i < l.
lldscaling.size(); ++i)
369 for (std::size_t i = 0; i < l.
cdscaling.size(); ++i)
371 for (std::size_t i = 0; i < l.
jdscaling.size(); ++i)
373 if (ld) refuse(
"LoadDependence",
"load, class or joint dependence is not represented.");
374 for (std::size_t i = 0; i < l.
pools.size(); ++i)
375 if (!l.
pools[i].empty()) refuse(
"ServerPools",
"heterogeneous server pools are not represented.");
376 for (std::size_t h = 1; h <= l.
nhosts; ++h) {
380 refuse(
"SchedStrategy",
"processor " + nm(h) +
" has scheduling " + schedName(s) +
381 "; only FCFS, SIRO, PS and INF are represented.");
387 refuse(
"SchedStrategy",
"task " + nm(t) +
" has scheduling " + schedName(s) +
388 "; only FCFS, SIRO, PS, INF and REF are represented.");
393 const std::size_t nb = countAndJoinBranches(j);
394 if (q >= 1 && q < nb)
395 refuse(
"AndJoinQuorum",
"AND-join " + nm(j) +
" has quorum " + std::to_string(q) +
" of " +
396 std::to_string(nb) +
" branches.");
400 if (t < l.
isref.size() && l.
isref[t]) refTasks_.push_back(t);
404 const double m = dbl(l.
arrival[e].mean);
405 if (m > tol() && m != std::numeric_limits<double>::infinity()) openEntries_.push_back(e);
407 if (refTasks_.empty() && openEntries_.empty())
408 throw InputError(
ErrorKind{
"Model"},
"LQN2PN: the LQN has no reference task and no open arrival.");
413 std::vector<Stage> callStages(std::size_t aidx) {
414 std::vector<Stage> stages;
415 if (aidx >= l_.
callsof.size())
return stages;
417 for (std::size_t cidx : l_.
callsof[aidx]) {
421 double nfull = std::floor(dbl(m) + tol());
422 T frac = T(m - tnum(nfull));
423 if (nfull >
double(MAXCALLSTAGES)) {
424 warn(
"call multiplicity " + fmtG(dbl(m)) +
" truncated to " + std::to_string(MAXCALLSTAGES) +
426 nfull = double(MAXCALLSTAGES);
431 for (std::size_t k = 0; k < static_cast<std::size_t>(nfull); ++k) stages.push_back(Stage{target, one, isasync});
432 if (dbl(frac) > tol()) stages.push_back(Stage{target, frac, isasync});
438 std::vector<std::pair<std::size_t, T> > forwardingOf(std::size_t eidx)
const {
439 std::vector<std::pair<std::size_t, T> > fwd;
441 for (std::size_t c = 1; c <= l_.
ncalls; ++c) {
444 if (dbl(p) < 0.0) p = zero;
445 if (dbl(p) > 1.0) p = one;
446 if (dbl(p) > tol()) fwd.push_back(std::make_pair(l_.
callpair_dst[c], p));
453 std::size_t fanOutOf(std::size_t a, std::size_t b, std::size_t rb)
const {
454 if (rb <= 1)
return 1;
455 double f = std::trunc(l_.
fanout_at(a, b));
457 const double ra = replRaw_[a];
458 f = double(rb) > ra ? std::max(1.0, std::floor(
double(rb) / ra)) : 1.0;
460 f = std::min(std::max(1.0, f),
double(rb));
461 return static_cast<std::size_t
>(f);
464 double taskCost(std::size_t tidx,
const std::set<std::size_t>& stack, std::map<std::size_t, double>& memo)
const {
465 if (stack.count(tidx))
return 1.0;
466 std::map<std::size_t, double>::const_iterator it = memo.find(tidx);
467 if (it != memo.end())
return it->second;
468 std::set<std::size_t> deeper = stack;
472 for (std::size_t eidx : l_.
entriesof[tidx]) {
473 std::vector<std::size_t> targets;
474 if (eidx < l_.
actsof.size())
475 for (std::size_t a : l_.
actsof[eidx])
477 for (std::size_t c : l_.
callsof[a])
480 const std::vector<std::pair<std::size_t, T> > fwd = forwardingOf(eidx);
481 for (std::size_t f = 0; f < fwd.size(); ++f) targets.push_back(fwd[f].first);
482 for (std::size_t te : targets) {
483 const std::size_t b = parent(te);
484 total += double(fanOutOf(tidx, b,
static_cast<std::size_t
>(replRaw_[b]))) *
485 taskCost(b, deeper, memo);
492 double instantiations()
const {
493 std::map<std::size_t, double> memo;
494 std::set<std::size_t> seeds(refTasks_.begin(), refTasks_.end());
495 for (std::size_t e : openEntries_) seeds.insert(parent(e));
497 for (std::size_t t : seeds) n += replRaw_[t] * taskCost(t, std::set<std::size_t>(), memo);
503 replRaw_.assign(NT + 1, 1.0);
504 std::vector<std::size_t> replicated;
505 for (std::size_t i = 1; i <= NT && i < l_.
repl.size(); ++i) {
506 replRaw_[i] = std::max(1.0, std::trunc(l_.
repl[i]));
507 if (replRaw_[i] > 1.0) replicated.push_back(i);
509 materialize_ = !replicated.empty() &&
510 (replication_ ==
"materialize" ||
511 (replication_ ==
"auto" && instantiations() <= double(MAXREPLINSTANCES)));
512 if (!replicated.empty() && !materialize_)
513 warn(
"replication of " + nm(replicated[0]) +
514 " is pooled: its replicas become r times the tokens of one processor, thread pool or "
515 "reference population.");
518 std::size_t nrep(std::size_t idx)
const {
519 return materialize_ ?
static_cast<std::size_t
>(replRaw_[idx]) : 1;
521 double poolFactor(std::size_t idx)
const {
return materialize_ ? 1.0 : replRaw_[idx]; }
523 std::vector<std::size_t> targetReplicas(std::size_t a, std::size_t arep, std::size_t b)
const {
524 const std::size_t rb = nrep(b);
525 if (rb <= 1)
return std::vector<std::size_t>(1, 0);
526 const std::size_t f = fanOutOf(a, b, rb);
527 std::vector<std::size_t> out;
528 for (std::size_t k = 0; k < f; ++k) out.push_back((arep * f + k) % rb);
532 Key hostKey(std::size_t tidx, std::size_t trep)
const {
533 const std::size_t h = parent(tidx);
534 return Key(h, trep % nrep(h));
539 std::size_t newPlace(
const std::string& base,
bool pinned =
false) {
540 places_.push_back(PlaceRec{unique(usedNode_, base), pinned});
541 uf_.push_back(uf_.size());
542 return places_.size() - 1;
545 std::size_t find(std::size_t p) {
546 while (uf_[p] != p) {
547 uf_[p] = uf_[uf_[p]];
554 void alias(std::size_t a, std::size_t b) {
555 const std::size_t ra = find(a), rb = find(b);
556 if (ra == rb)
return;
557 if (places_[ra].pinned && places_[rb].pinned)
559 places_[ra].name +
", " + places_[rb].name +
").");
560 const bool keepA = places_[ra].pinned || (!places_[rb].pinned && ra < rb);
567 std::size_t newClass(
const std::string& base,
bool open,
double pop, std::size_t ref,
569 classes_.push_back(ClassRec{unique(usedClass_, base), open, pop, ref, arrival});
570 return classes_.size() - 1;
573 std::size_t newTransition(
const std::string& base) {
574 trans_.push_back(TransRec{unique(usedNode_, base), std::vector<Mode>()});
575 return trans_.size() - 1;
579 void addMode(std::size_t ti,
const std::vector<Arc>& ins,
const std::vector<Arc>& outs,
const Dist* dist,
580 const T& weight,
bool hasPs =
false, Key ps = Key(0, 0)) {
581 TransRec&
tr = trans_[ti];
583 md.name =
tr.modes.empty() ?
tr.name :
tr.name +
"_" + std::to_string(
tr.modes.size() + 1);
586 md.immediate = dist ==
nullptr;
592 tr.modes.push_back(md);
596 void choice(
const std::string& tbase, std::size_t src, std::size_t tok,
const std::vector<Opt>& options) {
597 std::vector<Opt> opts;
598 for (
const Opt& o : options)
599 if (dbl(o.w) > tol()) opts.push_back(o);
600 if (opts.empty())
return;
601 if (opts.size() == 1 && opts[0].outs.size() == 1 && opts[0].outs[0].cls == tok &&
602 opts[0].outs[0].place != SINK) {
603 alias(src, opts[0].outs[0].place);
606 const std::size_t ti = newTransition(tbase);
607 for (
const Opt& o : opts) addMode(ti, std::vector<Arc>(1, Arc(src, tok)), o.outs,
nullptr, o.w);
612 Res cpuOf(
const Key& hkey) {
613 typename std::map<Key, Res>::const_iterator it = cpu_.find(hkey);
614 if (it != cpu_.end())
return it->second;
615 const std::size_t h = hkey.first, m = hkey.second;
616 const double c = imult(h) * poolFactor(h);
617 const std::size_t fr = newPlace(suffixed(nm(h) +
"_free", m),
true);
618 const std::size_t bz = newPlace(suffixed(nm(h) +
"_busy", m),
true);
619 const std::size_t cls = newClass(suffixed(nm(h) +
"_cpu", m),
false, c, fr);
620 marking_.push_back(Marking{fr, cls, c});
621 const Res r{cls, fr, bz, c};
626 bool hasPool(std::size_t tidx)
const {
627 return !(tidx < l_.
isref.size() && l_.
isref[tidx]) && mult(tidx) < 1e9 &&
631 Res thrOf(
const Key& tkey) {
632 std::map<Key, std::size_t>::const_iterator it = thrIdx_.find(tkey);
633 if (it != thrIdx_.end())
return thr_[it->second].second;
634 const std::size_t t = tkey.first, m = tkey.second;
635 const double c = imult(t) * poolFactor(t);
636 const std::size_t fr = newPlace(suffixed(nm(t) +
"_free", m),
true);
637 const std::size_t bz = newPlace(suffixed(nm(t) +
"_busy", m),
true);
638 const std::size_t cls = newClass(suffixed(nm(t) +
"_thread", m),
false, c, fr);
639 marking_.push_back(Marking{fr, cls, c});
640 const Res r{cls, fr, bz, c};
641 thrIdx_[tkey] = thr_.size();
642 thr_.push_back(std::make_pair(tkey, r));
646 std::size_t ph2Of(
const Key& tkey, std::size_t refPlace) {
647 std::map<Key, std::size_t>::const_iterator it = ph2cls_.find(tkey);
648 if (it != ph2cls_.end())
return it->second;
649 const std::size_t c = newClass(suffixed(nm(tkey.first) +
"_ph2", tkey.second),
false, 0.0, refPlace);
654 void demandSeg(std::size_t aidx, std::size_t tidx, std::size_t trep, std::size_t tok, std::size_t cur,
655 std::size_t nxt,
const Dist& dist) {
657 const Key hkey = hostKey(tidx, trep);
658 const std::size_t h = hkey.first;
660 const std::string aname = suffixed(nm(aidx), trep);
662 const std::size_t ti = newTransition(aname +
"_run");
663 addMode(ti, std::vector<Arc>(1, Arc(cur, tok)), std::vector<Arc>(1, Arc(nxt, tok)), &dist, one);
664 runPos_[hkey].push_back(std::make_pair(cur, tok));
668 " host demand on PS processor " + nm(h) +
669 "; only phase-type demands (Exp, Erlang, HyperExp, PH, APH, Coxian, "
670 "Cox2) have an exact image in the net, fit one first (e.g. "
671 "APH.fitMeanAndSCV).");
674 const std::size_t K = S.
rows();
675 std::vector<std::size_t>& pm = psModes_[hkey];
680 const std::size_t ti = newTransition(aname +
"_run");
681 addMode(ti, std::vector<Arc>(1, Arc(cur, tok)), std::vector<Arc>(1, Arc(nxt, tok)), &d1, one,
true,
683 psPos_[hkey].push_back(std::make_pair(cur, tok));
685 runPos_[hkey].push_back(std::make_pair(cur, tok));
696 std::size_t jmax = 0;
697 for (std::size_t j = 0; j < K; ++j) {
698 for (std::size_t k = 0; k < K; ++k) ext[j] = ext[j] - S(j, k);
699 if (dbl(ext[j]) > dbl(ext[jmax])) jmax = j;
701 std::vector<std::size_t> ph(K);
702 for (std::size_t k = 0; k < K; ++k) ph[k] = newPlace(aname +
"_ph" + std::to_string(k + 1));
703 std::vector<Opt> opts;
705 for (std::size_t k = 0; k < K; ++k) {
706 const T a = D1(jmax, k) / ext[jmax];
708 opts.push_back(Opt{a, std::vector<Arc>(1, Arc(ph[k], tok))});
710 if (1.0 - asum > tol())
712 choice(aname +
"_start", cur, tok, opts);
713 for (std::size_t j = 0; j < K; ++j) {
714 const std::size_t ti = newTransition(aname +
"_run" + std::to_string(j + 1));
715 for (std::size_t k = 0; k < K; ++k) {
716 if (k != j && dbl(S(j, k)) > tol()) {
718 addMode(ti, std::vector<Arc>(1, Arc(ph[j], tok)), std::vector<Arc>(1, Arc(ph[k], tok)), &dk,
722 if (dbl(ext[j]) > tol()) {
724 addMode(ti, std::vector<Arc>(1, Arc(ph[j], tok)), std::vector<Arc>(1, Arc(nxt, tok)), &dx, one,
729 for (std::size_t k = 0; k < K; ++k) {
730 psPos_[hkey].push_back(std::make_pair(ph[k], tok));
731 runPos_[hkey].push_back(std::make_pair(ph[k], tok));
734 const Res r = cpuOf(hkey);
735 const std::size_t srv = newPlace(aname +
"_srv");
736 const std::size_t tg = newTransition(aname +
"_get");
737 std::vector<Arc> gi, go;
738 gi.push_back(Arc(cur, tok));
739 gi.push_back(Arc(r.free, r.cls));
740 go.push_back(Arc(srv, tok));
741 go.push_back(Arc(r.busy, r.cls));
742 addMode(tg, gi, go,
nullptr, one);
743 const std::size_t
tr = newTransition(aname +
"_run");
744 std::vector<Arc> ri, ro;
745 ri.push_back(Arc(srv, tok));
746 ri.push_back(Arc(r.busy, r.cls));
747 ro.push_back(Arc(nxt, tok));
748 ro.push_back(Arc(r.free, r.cls));
749 addMode(
tr, ri, ro, &dist, one);
759 std::size_t expandEntry(std::size_t eidx, std::size_t trep, std::size_t tok, std::size_t ret) {
760 const Key key(eidx, trep);
761 if (std::find(entryStack_.begin(), entryStack_.end(), key) != entryStack_.end()) {
762 warn(
"recursive call cycle at entry " + nm(eidx) +
" truncated.");
766 if (eidx < l_.
actsof.size()) c.localActs = l_.
actsof[eidx];
767 std::size_t bound = NOPL;
768 for (std::size_t a : c.localActs)
769 if (dbl(l_.
graph.get(eidx, a)) != 0.0) {
773 if (bound == NOPL)
return NOPL;
774 entryStack_.push_back(key);
779 c.tidx = parent(eidx);
780 c.tkey = Key(c.tidx, trep);
781 c.ename = suffixed(nm(eidx), trep);
783 const std::size_t req = newPlace(c.ename +
"_req");
784 entryMap_.add(trep == 0 ? nm(eidx) : c.ename, req, tok);
785 c.pool = hasPool(c.tidx);
786 if (c.pool) c.poolRes = thrOf(c.tkey);
787 const std::size_t start = walk(c, bound, 1, NOPL);
789 const std::size_t ti = newTransition(c.ename +
"_acq");
790 std::vector<Arc> ins, outs;
791 ins.push_back(Arc(req, tok));
792 ins.push_back(Arc(c.poolRes.free, c.poolRes.cls));
793 outs.push_back(Arc(start, tok));
794 outs.push_back(Arc(c.poolRes.busy, c.poolRes.cls));
799 entryStack_.pop_back();
803 bool repliesHere(
const Ctx& c, std::size_t aidx)
const {
return replies_.count(Key(aidx, c.eidx)) > 0; }
805 std::size_t tokOf(Ctx& c,
int phase, std::size_t refPlace) {
806 if (phase == 1)
return c.tok;
807 return c.pool ? c.poolRes.cls : ph2Of(c.tkey, refPlace);
810 const std::vector<std::pair<T, std::size_t> >& forwards(Ctx& c) {
812 std::vector<std::pair<T, std::size_t> > opts;
813 const std::vector<std::pair<std::size_t, T> > rows = forwardingOf(c.eidx);
814 for (std::size_t i = 0; i < rows.size(); ++i) {
815 const std::size_t target = rows[i].first;
816 const std::vector<std::size_t> reps = targetReplicas(c.tidx, c.trep, parent(target));
817 for (std::size_t m : reps) {
818 const std::size_t r2 = expandEntry(target, m, c.tok, c.ret);
819 if (r2 != NOPL) opts.push_back(std::make_pair(T(rows[i].second / tnum(
double(reps.size()))), r2));
829 void emitReply(Ctx& c,
const std::string& aname, std::size_t x, std::size_t d2) {
831 std::vector<Arc> ins(1, Arc(x, c.tok));
832 std::vector<Arc> tail;
834 ins.push_back(Arc(c.poolRes.busy, c.poolRes.cls));
835 tail.push_back(Arc(d2 != NOPL ? d2 : c.poolRes.free, c.poolRes.cls));
836 }
else if (d2 != NOPL) {
837 tail.push_back(Arc(d2, ph2Of(c.tkey, d2)));
839 const std::vector<std::pair<T, std::size_t> > fw = forwards(c);
841 for (std::size_t i = 0; i < fw.size(); ++i) pf = T(pf + fw[i].first);
842 std::vector<Opt> own;
845 if (dbl(w0) < 0.0) w0 = zero;
848 if (c.ret != NOPL) o.outs.push_back(Arc(c.ret, c.tok));
849 o.outs.insert(o.outs.end(), tail.begin(), tail.end());
852 for (std::size_t i = 0; i < fw.size(); ++i) {
855 o.outs.push_back(Arc(fw[i].second, c.tok));
856 o.outs.insert(o.outs.end(), tail.begin(), tail.end());
859 std::vector<Opt> kept;
860 for (
const Opt& o : own)
861 if (dbl(o.w) > tol()) kept.push_back(o);
862 if (kept.size() == 1 && ins.size() == 1 && c.ret != NOPL && c.ret != SINK && tail.empty()) {
866 const std::size_t ti = newTransition(aname +
"_reply");
867 for (
const Opt& o : kept) addMode(ti, ins, o.outs,
nullptr, o.w);
870 void emitEnd(Ctx& c,
const std::string& aname, std::size_t x, std::size_t phaseTok) {
872 alias(x, c.poolRes.free);
874 const std::size_t ti = newTransition(aname +
"_end");
875 addMode(ti, std::vector<Arc>(1, Arc(x, phaseTok)), std::vector<Arc>(),
nullptr,
880 void body(Ctx& c, std::size_t aidx, std::size_t t, std::size_t cur, std::size_t out) {
882 const std::string aname = suffixed(nm(aidx), c.trep);
883 std::vector<Seg> segs;
898 const std::vector<Stage> stages = callStages(aidx);
899 for (std::size_t k = 0; k < stages.size(); ++k) {
910 for (std::size_t i = 0; i < segs.size(); ++i) {
911 const Seg& sg = segs[i];
912 const std::size_t nxt = i + 1 == segs.size() ? out : newPlace(aname +
"_s" + std::to_string(i + 1));
914 demandSeg(aidx, c.tidx, c.trep, t, cur, nxt, sg.d);
915 }
else if (sg.kind == 1) {
916 const std::size_t ti = newTransition(aname +
"_think");
917 addMode(ti, std::vector<Arc>(1, Arc(cur, t)), std::vector<Arc>(1, Arc(nxt, t)), &sg.d, one);
919 const std::string ks = std::to_string(sg.k);
920 const std::size_t target = sg.st.target;
921 const std::vector<std::size_t> reps = targetReplicas(c.tidx, c.trep, parent(target));
922 const T share = T(sg.st.prob / tnum(
double(reps.size())));
923 std::vector<Opt> opts;
924 for (std::size_t m : reps) {
926 const std::size_t acls = newClass(aname +
"_async" + ks,
false, 0.0, NOPL);
927 const std::size_t r2 = expandEntry(target, m, acls, NOPL);
929 classes_[acls].ref = nxt;
932 classes_[acls].ref = r2;
935 o.outs.push_back(Arc(nxt, t));
936 o.outs.push_back(Arc(r2, acls));
939 const std::size_t r2 = expandEntry(target, m, t, nxt);
940 if (r2 == NOPL)
continue;
943 o.outs.push_back(Arc(r2, t));
951 for (
const Opt& o : opts)
sum = T(
sum + o.w);
952 const T pin = T(one -
sum);
953 if (dbl(pin) > tol()) {
956 o.outs.push_back(Arc(nxt, t));
959 choice(aname +
"_call" + ks, cur, t, opts);
966 std::vector<std::size_t> localSucc(
const Ctx& c, std::size_t aidx)
const {
967 std::vector<std::size_t> out;
968 for (std::size_t s : c.localActs)
969 if (dbl(l_.
graph.get(aidx, s)) != 0.0) out.push_back(s);
973 std::size_t walk(Ctx& c, std::size_t aidx,
int phase, std::size_t refPlace) {
974 const std::pair<std::size_t, int> k(aidx, phase);
975 std::map<std::pair<std::size_t, int>, std::size_t>::const_iterator vit = c.visited.find(k);
976 if (vit != c.visited.end())
return vit->second;
977 const std::string aname = suffixed(nm(aidx), c.trep);
978 const std::size_t inP = newPlace(aname);
980 const std::size_t t = tokOf(c, phase, refPlace == NOPL ? inP : refPlace);
981 actMap_.add(c.trep == 0 ? nm(aidx) : aname, inP, t);
982 const std::size_t out = newPlace(aname +
"_out");
983 body(c, aidx, t, inP, out);
984 const std::vector<std::size_t> succ = localSucc(c, aidx);
985 if (phase == 1 && (repliesHere(c, aidx) || succ.empty())) {
986 if (!c.forkStack.empty() && succ.empty())
987 refuse(
"Structure",
"activity " + nm(aidx) +
" ends an AND-fork branch without an AND-join.");
989 const std::size_t d2 = newPlace(aname +
"_ph2");
990 emitReply(c, aname, out, d2);
993 emitReply(c, aname, out, NOPL);
998 if (!c.forkStack.empty())
999 refuse(
"Structure",
"activity " + nm(aidx) +
" ends an AND-fork branch without an AND-join.");
1000 emitEnd(c, aname, out, t);
1003 dispatch(c, aidx, succ, out, phase);
1007 std::size_t joinIndex(
const Ctx& c, std::size_t j)
const {
1008 for (std::size_t i = 0; i < c.joins.size(); ++i)
1009 if (c.joins[i].j == j)
return i;
1013 void dispatch(Ctx& c, std::size_t aidx,
const std::vector<std::size_t>& succ, std::size_t d,
int phase) {
1015 const std::string aname = suffixed(nm(aidx), c.trep);
1016 const std::size_t t = tokOf(c, phase, d);
1017 if (isAndJoinPre(aidx)) {
1018 const std::size_t j = succ[0];
1019 if (c.forkStack.empty()) {
1020 warn(
"AND-join at " + nm(j) +
" has no enclosing AND-fork; branches are serialised.");
1021 alias(d, walk(c, j, phase, NOPL));
1024 std::size_t ri = joinIndex(c, j);
1026 c.joins.push_back(JoinRec{j, c.forkStack.back(), std::vector<JoinIn>(),
false});
1027 ri = c.joins.size() - 1;
1028 }
else if (c.joins[ri].owner != c.forkStack.back()) {
1029 refuse(
"Structure",
"AND-join at " + nm(j) +
" merges branches of different AND-forks.");
1031 std::size_t place = NOPL;
1032 for (
const JoinIn& in : c.joins[ri].inputs)
1033 if (in.aidx == aidx) place = in.place;
1034 if (place == NOPL) {
1035 place = newPlace(suffixed(nm(j), c.trep) +
"_join" + std::to_string(c.joins[ri].inputs.size() + 1));
1036 c.joins[ri].inputs.push_back(JoinIn{aidx, place, t, phase});
1041 if (isAndFork(succ)) {
1042 c.forkStack.push_back(aidx);
1043 std::vector<Arc> outs;
1044 for (std::size_t s : succ) outs.push_back(Arc(walk(c, s, phase, d), t));
1045 c.forkStack.pop_back();
1046 const std::size_t ti = newTransition(aname +
"_fork");
1047 addMode(ti, std::vector<Arc>(1, Arc(d, t)), outs,
nullptr, one);
1048 std::vector<std::size_t> owned;
1049 for (
const JoinRec& r : c.joins)
1050 if (r.owner == aidx && !r.done) owned.push_back(r.j);
1051 for (std::size_t j : owned) finishJoin(c, j);
1054 std::vector<std::pair<T, std::size_t> > opts;
1055 for (std::size_t s : succ) {
1056 const T w = l_.
graph.get(aidx, s);
1057 if (dbl(w) > 0.0) opts.push_back(std::make_pair(w, s));
1059 if (opts.size() == 1) {
1060 alias(d, walk(c, opts[0].second, phase, d));
1063 const std::size_t ti = newTransition(aname +
"_or");
1064 for (std::size_t i = 0; i < opts.size(); ++i) {
1065 const std::size_t p = walk(c, opts[i].second, phase, d);
1066 addMode(ti, std::vector<Arc>(1, Arc(d, t)), std::vector<Arc>(1, Arc(p, t)),
nullptr, opts[i].first);
1070 void finishJoin(Ctx& c, std::size_t j) {
1071 const std::size_t ri = joinIndex(c, j);
1072 c.joins[ri].done =
true;
1073 const std::size_t nb = countAndJoinBranches(j);
1074 const std::vector<JoinIn> inputs = c.joins[ri].inputs;
1075 if (inputs.size() != nb)
1076 refuse(
"Structure",
"AND-join at " + nm(j) +
" is reached by " + std::to_string(inputs.size()) +
1077 " of its " + std::to_string(nb) +
" branches.");
1078 std::vector<Arc> ins;
1080 for (
const JoinIn& in : inputs) {
1081 ins.push_back(Arc(in.place, in.cls));
1082 if (in.phase == 2) ++n2;
1085 refuse(
"Structure",
"more than one branch of the AND-fork closed at " + nm(j) +
" replies.");
1086 const int phase = n2 > 0 ? 2 : 1;
1087 std::size_t ref = NOPL;
1088 for (
const JoinIn& in : inputs)
1089 if (in.phase == phase) {
1093 const std::size_t inJ = walk(c, j, phase, ref);
1094 const std::size_t ti = newTransition(suffixed(nm(j), c.trep) +
"_join");
1095 const std::size_t tk = tokOf(c, phase, ref);
1103 for (std::size_t refT : refTasks_) {
1104 for (std::size_t rep = 0; rep < nrep(refT); ++rep) {
1105 const std::string tn = suffixed(nm(refT), rep);
1106 const std::size_t tp = newPlace(tn +
"_think",
true);
1107 const double pop = imult(refT) * poolFactor(refT);
1108 const std::size_t cls = newClass(tn,
false, pop, tp);
1109 marking_.push_back(Marking{tp, cls, pop});
1110 thinkPlace_.push_back(std::make_pair(Key(refT, rep), tp));
1111 std::vector<std::size_t> reqs;
1113 for (std::size_t eidx : l_.
entriesof[refT]) {
1114 const std::size_t r = expandEntry(eidx, rep, cls, tp);
1115 if (r != NOPL) reqs.push_back(r);
1117 if (reqs.empty())
continue;
1118 std::size_t post = tp;
1119 if (refT < l_.
think.size() && timed(l_.
think[refT])) {
1120 post = newPlace(tn +
"_ready");
1121 const std::size_t tt = newTransition(tn +
"_thinking");
1122 addMode(tt, std::vector<Arc>(1, Arc(tp, cls)), std::vector<Arc>(1, Arc(post, cls)), &l_.
think[refT],
1125 if (reqs.size() == 1) {
1126 alias(post, reqs[0]);
1128 const std::size_t tc = newTransition(tn +
"_entry");
1129 for (std::size_t r : reqs)
1130 addMode(tc, std::vector<Arc>(1, Arc(post, cls)), std::vector<Arc>(1, Arc(r, cls)),
nullptr, one);
1135 for (std::size_t eidx : openEntries_) {
1136 for (std::size_t rep = 0; rep < nrep(parent(eidx)); ++rep) {
1137 const std::size_t cls = newClass(suffixed(nm(eidx) +
"_arrival", rep),
true, 0.0, NOPL, l_.
arrival[eidx]);
1138 const std::size_t r = expandEntry(eidx, rep, cls, SINK);
1140 warn(
"open arrival entry " + nm(eidx) +
" has no bound activity; ignored.");
1143 classes_[cls].ref = r;
1144 openSrc_.push_back(std::make_pair(cls, r));
1152 const double big = 1e9;
1153 for (std::size_t ti = 0; ti < trans_.size(); ++ti)
1154 for (std::size_t mi = 0; mi < trans_[ti].modes.size(); ++mi) {
1155 Mode& md = trans_[ti].modes[mi];
1156 if (!md.hasPs)
continue;
1157 const std::size_t ownP = find(md.ins[0].place), ownC = md.ins[0].cls;
1159 const std::vector<std::pair<std::size_t, std::size_t> >& cells = psPos_[md.ps];
1160 for (std::size_t q = 0; q < cells.size(); ++q)
1161 if (!(find(cells[q].first) == ownP && cells[q].second == ownC))
1162 md.inh.push_back(Arc(cells[q].first, cells[q].second, big));
1168 std::string placeName(std::size_t p) {
return p == SINK ? std::string(
"Sink") : places_[find(p)].name; }
1170 std::vector<Lqn2PnCell> cellsOf(
const std::vector<std::pair<std::size_t, std::size_t> >& lst) {
1171 std::vector<Lqn2PnCell> out;
1172 for (std::size_t i = 0; i < lst.size(); ++i) {
1173 Lqn2PnCell cell{placeName(lst[i].first), classes_[lst[i].second].name};
1176 if (o.place == cell.
place && o.cls == cell.
cls) seen =
true;
1177 if (!seen) out.push_back(cell);
1185 std::set<std::size_t> used;
1186 bool needsSink =
false;
1187 for (std::size_t ti = 0; ti < trans_.size(); ++ti)
1188 for (
const Mode& md : trans_[ti].modes) {
1189 for (
const Arc& a : md.ins)
1190 if (a.place != SINK) used.insert(find(a.place));
1191 for (
const Arc& a : md.outs) {
1192 if (a.place != SINK)
1193 used.insert(find(a.place));
1197 for (
const Arc& a : md.inh)
1198 if (a.place != SINK) used.insert(find(a.place));
1200 for (
const ClassRec& c : classes_)
1201 if (c.ref != NOPL) used.insert(find(c.ref));
1202 for (
const Marking& m : marking_) used.insert(find(m.place));
1204 const std::size_t src = openSrc_.empty() ? 0 : net.
add_source(
"Source");
1205 const std::size_t snk = (needsSink || !openSrc_.empty()) ? net.
add_sink(
"Sink") : 0;
1206 std::map<std::size_t, std::size_t> pnode;
1207 for (std::size_t p : used) pnode[p] = net.
add_place(places_[p].name);
1208 std::vector<std::size_t> tnode(trans_.size(), 0);
1209 for (std::size_t ti = 0; ti < trans_.size(); ++ti)
1210 if (!trans_[ti].modes.empty()) tnode[ti] = net.
add_transition(trans_[ti].name);
1212 std::vector<std::size_t> cobj;
1213 for (
const ClassRec& c : classes_) {
1221 "LQN2PN: internal error, closed class " + c.name +
" has no reference place.");
1222 cobj.push_back(net.
add_closed_class(c.name, std::trunc(c.pop), nodeOf(pnode, snk, c.ref), 0));
1227 for (std::size_t ti = 0; ti < trans_.size(); ++ti) {
1228 if (trans_[ti].modes.empty())
continue;
1229 const std::size_t
tr = tnode[ti];
1230 for (Mode& md : trans_[ti].modes) {
1231 const std::size_t k = net.
add_mode(
tr, md.name);
1239 for (
const Arc& a : md.ins) {
1240 const std::size_t pn = nodeOf(pnode, snk, a.place);
1242 R.
set(cobj[a.cls], cobj[a.cls], pn,
tr, one);
1244 for (
const Arc& a : md.outs) {
1245 const std::size_t pn = nodeOf(pnode, snk, a.place);
1247 R.
set(cobj[a.cls], cobj[a.cls],
tr, pn, one);
1249 for (
const Arc& a : md.inh)
1254 for (std::size_t i = 0; i < openSrc_.size(); ++i)
1255 R.
set(cobj[openSrc_[i].first], cobj[openSrc_[i].first], src, nodeOf(pnode, snk, openSrc_[i].second), one);
1259 const std::size_t K = net.
raw_struct().classes.size();
1260 for (
typename std::map<Key, std::vector<std::size_t> >::const_iterator it = psModes_.begin();
1261 it != psModes_.end(); ++it) {
1262 if (cpu_.count(it->first))
continue;
1263 const std::size_t h = it->first.first;
1264 const double cap = imult(h) * poolFactor(h);
1265 std::set<std::pair<std::size_t, std::size_t> > cells;
1266 const std::vector<std::pair<std::size_t, std::size_t> >& pos = psPos_[it->first];
1267 for (std::size_t q = 0; q < pos.size(); ++q)
1268 cells.insert(std::make_pair(nodeOf(pnode, snk, pos[q].first), cobj[pos[q].second]));
1269 std::vector<std::size_t> flat;
1270 for (
const std::pair<std::size_t, std::size_t>& ce : cells) flat.push_back((ce.first - 1) * K + (ce.second - 1));
1271 const std::function<T(
const std::vector<T>&)> g = [flat, cap](
const std::vector<T>& mk) -> T {
1273 for (std::size_t q = 0; q < flat.size(); ++q) n = T(n + mk[flat[q]]);
1277 for (std::size_t ti : it->second)
1281 for (std::map<std::size_t, std::size_t>::const_iterator it = pnode.begin(); it != pnode.end(); ++it) {
1282 std::vector<T> st(K, zero);
1283 for (
const Marking& m : marking_)
1284 if (find(m.place) == it->first) st[cobj[m.cls] - 1] = T(st[cobj[m.cls] - 1] + tnum(std::trunc(m.v)));
1288 if (map_ !=
nullptr) fillMap();
1292 std::size_t nodeOf(
const std::map<std::size_t, std::size_t>& pnode, std::size_t snk, std::size_t p) {
1293 if (p == SINK)
return snk;
1294 return pnode.at(find(p));
1300 for (std::size_t h = 1; h <= l_.
nhosts; ++h)
1301 for (std::size_t m = 0; m < nrep(h); ++m) {
1302 const Key hkey(h, m);
1304 pr.
name = suffixed(nm(h), m);
1305 pr.
sched = schedName(sched(h));
1306 typename std::map<Key, Res>::const_iterator ci = cpu_.find(hkey);
1307 if (ci != cpu_.end()) {
1308 pr.
mult = ci->second.mult;
1309 pr.
busy.push_back(
Lqn2PnCell{placeName(ci->second.busy), classes_[ci->second.cls].name});
1311 }
else if (runPos_.count(hkey)) {
1312 const double mm = mult(h) * poolFactor(h);
1313 pr.
mult = mm >= 1e9 ? std::numeric_limits<double>::infinity() : mm;
1314 pr.
run = cellsOf(runPos_[hkey]);
1318 std::map<std::string, std::size_t> tpos;
1319 for (std::size_t i = 0; i < thr_.size(); ++i) {
1320 const Key& tk = thr_[i].first;
1321 const Res& r = thr_[i].second;
1323 tsk.
name = suffixed(nm(tk.first), tk.second);
1328 upsertTask(mp, tpos, tsk);
1330 for (std::size_t i = 0; i < thinkPlace_.size(); ++i) {
1331 const std::size_t t = thinkPlace_[i].first.first, m = thinkPlace_[i].first.second;
1333 tsk.
name = suffixed(nm(t), m);
1334 tsk.
mult = imult(t) * poolFactor(t);
1336 tsk.
think =
Lqn2PnCell{placeName(thinkPlace_[i].second), suffixed(nm(t), m)};
1337 upsertTask(mp, tpos, tsk);
1339 for (std::size_t i = 0; i < entryMap_.rows.size(); ++i)
1340 mp.
entries.push_back(
Lqn2PnElement{entryMap_.rows[i].first, cellsOf(entryMap_.rows[i].second)});
1341 for (std::size_t i = 0; i < actMap_.rows.size(); ++i)
1346 static void upsertTask(
Lqn2PnMap& mp, std::map<std::string, std::size_t>& tpos,
const Lqn2PnTask& tsk) {
1347 std::map<std::string, std::size_t>::const_iterator it = tpos.find(tsk.
name);
1348 if (it == tpos.end()) {
1350 mp.
tasks.push_back(tsk);
1352 mp.
tasks[it->second] = tsk;
1372 const std::string& name =
"model", std::vector<std::string>* warnings =
nullptr,
1375 const std::set<std::pair<std::size_t, std::size_t> > replies = detail::lqn2qn_replies(
lqn, l);
1376 detail::Lqn2Pn<T> conv(l, replies, replication, name, warnings, map);
1388 const std::string& name =
"model", std::vector<std::string>* warnings =
nullptr,
1390 const std::set<std::pair<std::size_t, std::size_t> > replies = detail::lqn2qn_replies(
lqn::LqnModel<T>(),
lsn);
1391 detail::Lqn2Pn<T> conv(
lsn, replies, replication, name, warnings, map);
InternalError(const std::string &what)
UnsupportedError(const std::string &what)
A queueing network under construction.
std::size_t add_source(const std::string &nm)
The external arrival station.
void set_enabling_conditions(std::size_t node, std::size_t mode, std::size_t cls, std::size_t place, const T &tokens)
Transition.setEnablingConditions(mode, class, place, tokens): how many class-r tokens the mode needs ...
std::size_t add_open_class(const std::string &nm, int prio=0)
An open class.
void set_mode_timing(std::size_t node, std::size_t mode, lang::TimingStrategy ts)
Transition.setTimingStrategy(mode, strategy): TIMED or IMMEDIATE.
void set_firing_weight(std::size_t node, std::size_t mode, const T &w)
Transition.setFiringWeights(mode, weight): the share among tied modes.
RoutingMatrix< T > init_routing_matrix() const
An empty routing matrix, MATLAB's model.initRoutingMatrix.
void set_mode_distribution(std::size_t node, std::size_t mode, const Distrib< T > &d)
Transition.setDistribution(mode, dist): the mode's firing law.
void set_initial_marking(std::size_t node, const std::vector< T > &tokens)
Place.setState(marking): the initial token count of the place, per class.
void set_inhibiting_conditions(std::size_t node, std::size_t mode, std::size_t cls, std::size_t place, const T &tokens)
Transition.setInhibitingConditions(mode, class, place, tokens): the class-r count at place that BLOCK...
void set_mode_firing_dependence(std::size_t node, std::size_t mode, const std::function< T(const std::vector< T > &)> &g)
Transition.setFiringRateDependence(mode, g): g(marking) scales the rate.
std::size_t add_mode(std::size_t node, const std::string &nm)
Transition.addMode(name): a new firing mode, returning its 1-based index.
std::size_t add_closed_class(const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
A closed class of the given population, referencing a station node.
std::size_t add_sink(const std::string &nm)
The external departure node.
std::size_t add_place(const std::string &nm)
A Place: an SPN token container.
NetworkStruct< T > & raw_struct()
The struct WITHOUT refreshing it, for a caller that is still building.
void link(const RoutingMatrix< T > &Pm)
model.link(P): install the routing.
void set_mode_servers(std::size_t node, std::size_t mode, double n)
Transition.setNumberOfServers(mode, n); GlobalConstants::MaxInt is infinite.
void set_firing_outcome(std::size_t node, std::size_t mode, std::size_t cls, std::size_t dest, const T &tokens)
Transition.setFiringOutcome(mode, class, node, tokens): the class-r tokens the firing deposits.
std::size_t add_transition(const std::string &nm, const TransitionParam< T > &par)
A Transition: the firing rules of an SPN, as Transition in MATLAB.
void set_arrival(std::size_t node, std::size_t cls, const Distrib< T > &d)
source.setArrival(class, dist): the same table, at the Source.
The routing matrix a model script fills in, MATLAB's P cell array.
void set(std::size_t r, std::size_t s, std::size_t i, std::size_t j, const T &p)
The exception types the port throws.
int dispatch(const Options &in, bool allow_server, bool no_args)
Everything main did, with the arguments already in hand.
Convert a layered queueing network into a single queueing network in which synchronous call blocking ...
.lqnx -> LqnStruct, a port of matlab/src/lang/layered/@LayeredNetwork/parseXML.m followed by ....
LayeredNetworkStruct, the flattened description of a layered queueing network.
qn::Network< T > lqn2pn(const lqn::LqnModel< T > &lqn, const std::string &replication="auto", const std::string &name="model", std::vector< std::string > *warnings=nullptr, Lqn2PnMap *map=nullptr)
Port of Python LQN2PN(lqn, replication, return_map) and MATLAB LQN2PN: convert a layered network into...
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
@ IMMEDIATE
fires with zero delay, resolved by weight and priority
CallType
Call kinds, with the values of MATLAB CallType.
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
const char * sched_to_text(SchedStrategy s)
const char * process_to_text(ProcessType p)
The MATLAB ProcessType name, as sn.procid prints it.
LqnStruct< T > lqn_finalize(const LqnModel< T > &m)
Port of @LayeredNetwork/getStruct.m: flatten the model into its struct.
Conservation laws of a layered queueing network, enumerated from its structure.
lang::Distrib< double > Dist
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
Number-type abstraction for the templated API port.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
A (place, class) pair of the Petri net, by node and class NAME.
The (place, class) copies of an entry or activity whose Tput sums to its throughput.
std::vector< Lqn2PnCell > cells
The result map of LQN2PN, the twin of the Python return_map dictionary, insertion-ordered.
std::vector< Lqn2PnProcessor > processors
std::vector< Lqn2PnElement > entries
std::vector< Lqn2PnElement > activities
std::vector< Lqn2PnTask > tasks
Where to read a processor replica.
std::vector< Lqn2PnCell > busy
std::string sched
scheduling, as the Python enum name (FCFS, SIRO, PS, INF)
std::vector< Lqn2PnCell > run
std::string name
processor name, _r<k> suffixed for replica k >= 2
Where to read a task replica.
bool is_immediate() const
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
static Distrib exp_rate(const T &r)
static Distrib disabled_dist()
static constexpr double FineTol
static constexpr double MaxInt
Stand-in for an unbounded COUNT, MATLAB GlobalConstants.MaxInt.
The intermediate model, and the second stage that flattens it.
std::vector< Distrib< T > > hostdem
(nidx+1) host demand per activity (Immediate elsewhere)
std::vector< CallType > calltype
(ncalls+1)
std::vector< std::size_t > callpair_dst
(ncalls+1) called entry
std::vector< bool > hassetup
(tshift+ntasks+1)
std::vector< Distrib< T > > actthink
(nidx+1) activity think time
std::vector< std::vector< T > > lldscaling
Queue-dependent service rates declared on a layer server (a host or a task), by element index,...
std::vector< double > mult
(tshift+ntasks+1) declared multiplicity, may be Inf
std::vector< SchedStrategy > sched
(tshift+ntasks+1)
std::vector< std::size_t > callpair_src
(ncalls+1) calling activity (entry for FWD)
std::vector< std::size_t > parent
(nidx+1) host of a task, task of an entry/activity
std::vector< ServerPools< T > > pools
(tshift+ntasks+1)
std::vector< T > callproc_mean
(ncalls+1) mean number of calls
std::vector< std::size_t > actquorum
(nidx+1) AND-join quorum, on the join target
std::vector< bool > iscache
(tshift+ntasks+1)
std::vector< bool > has_arrival
(nidx+1) entry with an open arrival
std::vector< std::vector< std::size_t > > callsof
(nidx+1) call indices issued by an activity
std::vector< CdScaling< T > > cdscaling
(tshift+ntasks+1)
std::vector< std::vector< std::size_t > > entriesof
(tshift+ntasks+1)
double fanout_at(std::size_t i, std::size_t j) const
fan-out from caller task i to callee task j; 0 when undeclared.
std::vector< double > repl
(tshift+ntasks+1) replication
std::vector< std::string > names
(nidx+1) declared name
std::vector< Matrix< T > > lincon_A
Admission constraint A n <= b on the layer station of a host or task.
std::vector< Distrib< T > > think
(nidx+1) task think time
std::vector< bool > isref
(tshift+ntasks+1)
std::vector< PrecedenceType > actpretype
(nidx+1)
std::vector< std::vector< std::size_t > > actsof
(ashift+1) by task and by entry
std::vector< PrecedenceType > actposttype
(nidx+1)
std::vector< Distrib< T > > arrival
(nidx+1) open arrival process of an entry
std::vector< CdScaling< T > > jdscaling
(tshift+ntasks+1)
SparseGraph< T > graph
element call/precedence graph, edge weights are branch shares