LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
nodes.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_LANG_QN_NODES_H
6#define LINE_LANG_QN_NODES_H
7
8/**
9 * @file
10 * @ingroup line_lang
11 * @ingroup line_public
12 * The model API a user writes, spelled as its Python twin.
13 *
14 * Network model("model");
15 * Delay delay (model, "Delay");
16 * Queue queue1(model, "Queue1", SchedStrategy::PS);
17 * Source source(model, "Source");
18 * Sink sink (model, "Sink");
19 * ClosedClass closed(model, "ClosedClass", 2, delay, 0);
20 * queue1.set_service(closed, Exp(1.0));
21 *
22 * against Python's
23 *
24 * model = Network('model')
25 * delay = Delay(model, 'Delay')
26 * queue1 = Queue(model, 'Queue1', SchedStrategy.PS)
27 * closed = ClosedClass(model, 'ClosedClass', 2, delay, 0)
28 * queue1.set_service(closed, Exp(1.0))
29 *
30 * EVERY CLASS HERE IS A HANDLE, NOT A NODE. It holds the model and the 1-based
31 * index `qn::Network` already returns, and every method forwards to the builder
32 * call of the same name -- `network_builder.h` remains the engine and is not
33 * touched. That is what lets old and new code mix: a handle CONVERTS to its
34 * index, so it drops straight into `RoutingMatrix::set` and into any call still
35 * written against the index API.
36 *
37 * The handles are `double`-only, as Python is. The templated
38 * `qn::Network<T>` stays reachable for the multiprecision paths.
39 */
40
41#include <cstddef>
42#include <functional>
43#include <map>
44#include <string>
45#include <vector>
46
49
50namespace line {
51
55
56class JobClass;
57
58/** A node of the model: the index it was given, and the model that owns it. */
59class Node {
60 public:
61 /** `get_index()`: the 1-based node index the builder assigned. */
62 std::size_t get_index() const { return idx_; }
63 /** `getName()`. */
64 const std::string& get_name() const { return name_; }
65 /** The model this node belongs to. */
66 NetworkModel& model() const { return *model_; }
67
68 /**
69 * A handle IS its index wherever one is expected.
70 *
71 * This is what lets `P.set(closed, closed, delay, queue1, 1.0)` take
72 * handles, and what lets a half-migrated example keep compiling.
73 */
74 operator std::size_t() const { return idx_; }
75
76 /** `setRouting(class, strategy)`. */
77 void set_routing(std::size_t cls, lang::RoutingStrategy rs) {
78 model_->set_routing(idx_, cls, rs);
79 }
80 /** `setRoutingWeight(class, weights)`: the WRROBIN share per destination. */
81 void set_routing_weights(std::size_t cls, const std::map<std::size_t, double>& weights) {
82 model_->set_routing_weights(idx_, cls, weights);
83 }
84
85 protected:
86 Node(NetworkModel& m, std::size_t idx, const std::string& nm)
87 : model_(&m), idx_(idx), name_(nm) {}
89 std::size_t idx_;
90 std::string name_;
91};
92
93/** A node that holds jobs and serves them: MATLAB's `Station`. */
94class Station : public Node {
95 public:
96 /** `setService(class, distribution)`. */
97 void set_service(std::size_t cls, const Dist& d) { model_->set_service(idx_, cls, d); }
98 /** `setNumberOfServers(n)`. */
100 /** `setCapacity(k)`, the K of Kendall's notation. */
101 void set_capacity(double k) { model_->set_capacity(idx_, k); }
102 /** `setClassCapacity(class, k)`. */
103 void set_class_capacity(std::size_t cls, double k) {
105 }
106 /** `setDropRule(class, rule)`. */
107 void set_drop_rule(std::size_t cls, lang::DropStrategy rule) {
108 model_->set_drop_rule(idx_, cls, rule);
109 }
110 /** `setSchedParam(class, weight)`: the DPS/GPS share. */
111 void set_sched_param(std::size_t cls, double weight) {
112 model_->set_sched_param(idx_, cls, weight);
113 }
114 /** `setLoadDependence(alpha)`. */
115 void set_load_dependence(const std::vector<double>& alpha) {
117 }
118 /** `setPollingType(type, k)`. */
119 void set_polling_type(lang::PollingType rule, int par = 0) {
120 model_->set_polling_type(idx_, rule, par);
121 }
122 /** `setSwitchover(class, distribution)`. */
123 void set_switchover(std::size_t cls, const Dist& so) {
124 model_->set_switchover(idx_, cls, so);
125 }
126 /** `setSwitchover(fromClass, toClass, distribution)`. */
127 void set_switchover(std::size_t from_cls, std::size_t to_cls, const Dist& so) {
128 model_->set_switchover(idx_, from_cls, to_cls, so);
129 }
130 /** `setBreakdown(failure, repair)`. */
131 void set_breakdown(const Dist& failure, const Dist& repair) {
132 model_->set_breakdown(idx_, failure, repair);
133 }
134 /** `addServerType(type)`: one pool of a heterogeneous station. */
138 /** `getStationIndex()`: the 1-based station index, distinct from the node one. */
139 std::size_t get_station_index() const { return model_->station_index(idx_); }
140
141 protected:
142 Station(NetworkModel& m, std::size_t idx, const std::string& nm) : Node(m, idx, nm) {}
143};
144
145/** `Queue(model, name, strategy)`. */
146class Queue : public Station {
147 public:
148 Queue(NetworkModel& m, const std::string& nm,
150 : Station(m, m.add_queue(nm, sched), nm) {}
151};
152
153/** `Delay(model, name)`: the infinite-server station. */
154class Delay : public Station {
155 public:
156 Delay(NetworkModel& m, const std::string& nm) : Station(m, m.add_delay(nm), nm) {}
157};
158
159/** `Source(model, name)`: the external arrival station. */
160class Source : public Station {
161 public:
162 Source(NetworkModel& m, const std::string& nm) : Station(m, m.add_source(nm), nm) {}
163 /** `setArrival(class, distribution)`. */
164 void set_arrival(std::size_t cls, const Dist& d) { model_->set_arrival(idx_, cls, d); }
165 /** `setArrivalBatch(class, batchSizeDist)`. */
166 void set_arrival_batch(std::size_t cls, const Dist& d) {
167 model_->set_arrival_batch(idx_, cls, d);
168 }
169 /**
170 * `setMarkedArrival(process, classes)`: bind a MARKED arrival process, one
171 * class per mark.
172 *
173 * A mark is a label the process attaches to each event, and here it selects
174 * the CLASS of the arriving job: mark k emits jobs of `classes[k-1]`, with
175 * all marks driven by ONE shared modulating chain. That sharing is the point
176 * and it is why this is not `set_arrival` per class with copies of the
177 * process: K copies are K independent streams. The binding IS the order of
178 * `classes`.
179 *
180 * Takes any marked family the engine declares: MMAP and MPH (stationary),
181 * MMAPt and MPHt (schedule-bearing), or BMMAPt, whose epochs also release a
182 * BATCH of jobs that all carry the mark's class.
183 */
184 void set_marked_arrival(const Dist& d, const std::vector<std::size_t>& classes) {
185 for (std::size_t k = 0; k < classes.size(); ++k)
186 model_->set_arrival(idx_, classes[k], d);
187 model_->set_marked_classes(idx_, classes);
188 }
189};
190
191/** `Sink(model, name)`: the external departure node, which holds no jobs. */
192class Sink : public Node {
193 public:
194 Sink(NetworkModel& m, const std::string& nm) : Node(m, m.add_sink(nm), nm) {}
195};
196
197/** `Router(model, name)`: a stateless routing node. */
198class Router : public Node {
199 public:
200 Router(NetworkModel& m, const std::string& nm) : Node(m, m.add_router(nm), nm) {}
201};
202
203/** `ClassSwitch(model, name, C)`. */
204class ClassSwitch : public Node {
205 public:
206 ClassSwitch(NetworkModel& m, const std::string& nm, const Matrix<double>& C)
207 : Node(m, m.add_class_switch(nm), nm) {
209 }
210 /** `setClassSwitchingMatrix(C)`. */
214};
215
216/** `Fork(model, name)`. */
217class Fork : public Node {
218 public:
219 Fork(NetworkModel& m, const std::string& nm, double tasks_per_link = 1.0)
220 : Node(m, m.add_fork(nm, tasks_per_link), nm) {}
221};
222
223/** `Join(model, name, fork)`. */
224class Join : public Node {
225 public:
226 Join(NetworkModel& m, const std::string& nm, std::size_t fork_node)
227 : Node(m, m.add_join(nm, fork_node), nm) {}
228 /** `setStrategy(strategy, quorum)`. */
229 void set_strategy(lang::JoinStrategy strategy, double quorum = 0.0) {
230 model_->set_join_strategy(idx_, strategy, quorum);
231 }
232};
233
234/** `Cache(model, name, params)`. */
235class Cache : public Node {
236 public:
237 Cache(NetworkModel& m, const std::string& nm, const qn::CacheParam<double>& par)
238 : Node(m, m.add_cache(nm, par), nm) {}
239 /** `setItemReadClasses(read_classes, hit_classes)`, one entry per item. */
240 void set_item_read_classes(const std::vector<std::size_t>& read_classes,
241 const std::vector<std::size_t>& hit_classes) {
242 model_->set_item_read_classes(idx_, read_classes, hit_classes);
243 }
244 /** `setRead(jobclass, popularity)`: a pmf over the item ranks 1..nitems. */
245 void set_read(std::size_t cls, const std::vector<double>& pmf) { model_->set_cache_read(idx_, cls, pmf); }
246 /** `setRead(jobclass, Zipf(s, n))` or `setRead(jobclass, DiscreteSampler(p))`. */
247 void set_read(std::size_t cls, const lang::Distrib<double>& d) { model_->set_cache_read(idx_, cls, d); }
248 /** `setHitClass(jobclass, hitclass)`. */
249 void set_hit_class(std::size_t cls, std::size_t hit) { model_->set_cache_hit_class(idx_, cls, hit); }
250 /** `setMissClass(jobclass, missclass)`. */
251 void set_miss_class(std::size_t cls, std::size_t miss) { model_->set_cache_miss_class(idx_, cls, miss); }
252};
253
254/** `Place(model, name)`: a Petri-net place. */
255class Place : public Station {
256 public:
257 Place(NetworkModel& m, const std::string& nm) : Station(m, m.add_place(nm), nm) {}
258 /**
259 * `Place(model, name, schedStrategy)`: a place with an EMBEDDED QUEUE.
260 *
261 * The place becomes a queueing place once `set_service` gives it a law, as
262 * `Place.setService` does in MATLAB; until then the discipline is declared
263 * and unused and the place behaves as an ordinary one.
264 */
265 Place(NetworkModel& m, const std::string& nm, lang::SchedStrategy sched)
266 : Station(m, m.add_place(nm, sched), nm) {}
267 /** `setDepartureDiscipline(class, rule)`: how a served token leaves the depository. */
270 }
271 /** `setInitialMarking(tokens)`. */
272 void set_initial_marking(const std::vector<double>& tokens) {
274 }
275 /** `setFluid(flag)`: a FLUID place of an FSPN, holding one real level instead of tokens. */
276 void set_fluid(bool flag = true) { model_->set_place_fluid(idx_, flag); }
277 /** `isFluid()`. */
278 bool is_fluid() const { return model_->is_place_fluid(idx_); }
279 /** `setFluidCapacity(B)`: the level ceiling, Inf when unbounded. */
281 /** `getFluidCapacity()`. */
283 /** `setFluidLevel(x0)`: the initial level. */
284 void set_fluid_level(double level) { model_->set_fluid_level(idx_, level); }
285 /** `getFluidLevel()`. */
286 double get_fluid_level() const { return model_->get_fluid_level(idx_); }
287};
288
289/**
290 * `Transition(model, name)`: a Petri-net transition, with its modes declared
291 * after it as MATLAB, the JAR and Python declare theirs.
292 *
293 * Transition t1(model, "T1");
294 * const std::size_t mode1 = t1.add_mode("Mode1");
295 * t1.set_distribution(mode1, Exp(2.0));
296 * t1.set_enabling_conditions(mode1, c1, p1, 2);
297 * t1.set_firing_outcome(mode1, c1, p2, 2);
298 *
299 * THE ARCS TAKE HANDLES, not indices: a `Place` where a place is meant and a
300 * `JobClass` where a class is meant, so mixing the two is a compile error.
301 * Both convert to `std::size_t`, which is exactly what made them
302 * interchangeable at a call site written against the index API.
303 */
304class Transition : public Node {
305 public:
306 Transition(NetworkModel& m, const std::string& nm) : Node(m, m.add_transition(nm), nm) {}
307 /** The all-at-once form, for a caller that already holds a finished block. */
308 Transition(NetworkModel& m, const std::string& nm, const qn::TransitionParam<double>& par)
309 : Node(m, m.add_transition(nm, par), nm) {}
310
311 /** `addMode(name)`: the new mode's 1-based index. */
312 std::size_t add_mode(const std::string& nm) { return model_->add_mode(idx_, nm); }
313 /** `setDistribution(mode, dist)`: the mode's firing law. */
314 void set_distribution(std::size_t mode, const Dist& d) {
316 }
317 /** `setTimingStrategy(mode, strategy)`: TIMED or IMMEDIATE. */
318 void set_timing_strategy(std::size_t mode, lang::TimingStrategy ts) {
319 model_->set_mode_timing(idx_, mode, ts);
320 }
321 /** `setNumberOfServers(mode, n)`; `GlobalConstants::MaxInt` is infinite. */
322 void set_number_of_servers(std::size_t mode, double n) {
323 model_->set_mode_servers(idx_, mode, n);
324 }
325 /** `setFiringPriorities(mode, priority)`. */
326 void set_firing_priorities(std::size_t mode, double prio) {
327 model_->set_firing_priority(idx_, mode, prio);
328 }
329 /** `setFiringWeights(mode, weight)`: the share among simultaneously enabled modes. */
330 void set_firing_weights(std::size_t mode, double w) {
331 model_->set_firing_weight(idx_, mode, w);
332 }
333 /** `setFiringRateDependence(mode, g)`: g(marking) scales the firing rate. */
335 std::size_t mode, const std::function<double(const std::vector<double>&)>& g) {
337 }
338 /** `setFluidRate(mode, place, rate)`: flow per running server into (> 0) or out of (< 0) a fluid place. */
339 void set_fluid_rate(std::size_t mode, const Place& place, double rate) {
340 model_->set_mode_fluid_rate(idx_, mode, place.get_index(), rate);
341 }
342 /** `setFluidGuard(mode, place, op, threshold)`: op ">=" or "<="; an empty op removes the guard. */
343 void set_fluid_guard(std::size_t mode, const Place& place, const std::string& op, double threshold) {
344 model_->set_mode_fluid_guard(idx_, mode, place.get_index(), op, threshold);
345 }
346 /** `setFluidImpulse(mode, place, delta)`: the level jump on every firing of the mode. */
347 void set_fluid_impulse(std::size_t mode, const Place& place, double delta) {
348 model_->set_mode_fluid_impulse(idx_, mode, place.get_index(), delta);
349 }
350 /** `setFluidRateDependence(mode, place, h)`: h(level) scales the firing rate of a timed Exp mode. */
351 void set_fluid_rate_dependence(std::size_t mode, const Place& place,
352 const std::function<double(double)>& h) {
354 }
355 /**
356 * `setFluidFlowDependence(mode, place, phi[, readPlaces])`: the flow on the fluid place becomes
357 * k * rate * phi(M), M the flattened (nnodes x nclasses) marking holding the token places `read`
358 * (default: the mode's input places), entry (i-1)*nclasses + (r-1). An empty `phi` removes it.
359 */
360 void set_fluid_flow_dependence(std::size_t mode, const Place& place,
361 const std::function<double(const std::vector<double>&)>& phi,
362 const std::vector<Place>& read = std::vector<Place>()) {
363 std::vector<std::size_t> rd;
364 for (const Place& p : read) rd.push_back(p.get_index());
365 model_->set_mode_fluid_flow_dependence(idx_, mode, place.get_index(), phi, rd);
366 }
367 /** `hasFluidArcs()`. */
368 bool has_fluid_arcs() const { return model_->has_fluid_arcs(idx_); }
369 /** `setEnablingConditions(mode, class, place, tokens)`. */
370 void set_enabling_conditions(std::size_t mode, const JobClass& cls, const Place& place,
371 double tokens);
372 /** `setInhibitingConditions(mode, class, place, tokens)`; absent means never. */
373 void set_inhibiting_conditions(std::size_t mode, const JobClass& cls, const Place& place,
374 double tokens);
375 /** `setFiringOutcome(mode, class, node, tokens)`; the node may be a Sink. */
376 void set_firing_outcome(std::size_t mode, const JobClass& cls, const Node& dest,
377 double tokens);
378};
379
380// ---------------------------------------------------------------------------
381// Job classes
382// ---------------------------------------------------------------------------
383
384/** A job class: the index it was given, and the model that owns it. */
385class JobClass {
386 public:
387 /** `get_index()`: the 1-based class index. */
388 std::size_t get_index() const { return idx_; }
389 /** `getName()`. */
390 const std::string& get_name() const { return name_; }
391 /** A handle IS its index wherever one is expected. */
392 operator std::size_t() const { return idx_; }
393 /** `completes = flag`: whether passing the reference station completes the chain's cycle. */
394 void set_completes(bool flag) { model_->set_class_completes(idx_, flag); }
395
396 protected:
397 JobClass(NetworkModel& m, std::size_t idx, const std::string& nm)
398 : model_(&m), idx_(idx), name_(nm) {}
400 std::size_t idx_;
401 std::string name_;
402};
403
404/** `ClosedClass(model, name, njobs, refstat, prio)`. */
405class ClosedClass : public JobClass {
406 public:
407 ClosedClass(NetworkModel& m, const std::string& nm, double njobs, std::size_t refstat_node,
408 int prio = 0)
409 : JobClass(m, m.add_closed_class(nm, njobs, refstat_node, prio), nm) {}
410};
411
412/** `OpenClass(model, name, prio)`. */
413class OpenClass : public JobClass {
414 public:
415 OpenClass(NetworkModel& m, const std::string& nm, int prio = 0)
416 : JobClass(m, m.add_open_class(nm, prio), nm) {}
417};
418
419/** `SelfLoopingClass(model, name, njobs, refstat, prio)`. */
421 public:
422 SelfLoopingClass(NetworkModel& m, const std::string& nm, double njobs,
423 std::size_t refstat_node, int prio = 0)
424 : JobClass(m, m.add_self_looping_class(nm, njobs, refstat_node, prio), nm) {}
425};
426
427
428// The three arc setters of `Transition`, defined here because they name
429// `JobClass`, which is declared below the node handles.
430
431inline void Transition::set_enabling_conditions(std::size_t mode, const JobClass& cls,
432 const Place& place, double tokens) {
433 model_->set_enabling_conditions(idx_, mode, cls.get_index(), place.get_index(), tokens);
434}
435
436inline void Transition::set_inhibiting_conditions(std::size_t mode, const JobClass& cls,
437 const Place& place, double tokens) {
438 model_->set_inhibiting_conditions(idx_, mode, cls.get_index(), place.get_index(), tokens);
439}
440
441inline void Transition::set_firing_outcome(std::size_t mode, const JobClass& cls,
442 const Node& dest, double tokens) {
443 model_->set_firing_outcome(idx_, mode, cls.get_index(), dest.get_index(), tokens);
444}
445
446// ---------------------------------------------------------------------------
447// Routing helpers, MATLAB's static Network methods
448// ---------------------------------------------------------------------------
449
450/** `Network.serialRouting(nodes)` for one class pair: 1 -> 2 -> ... -> n. */
451inline void serial_routing(Routing& P, std::size_t r, std::size_t s,
452 const std::vector<std::size_t>& nodes) {
453 for (std::size_t k = 0; k + 1 < nodes.size(); ++k) P.set(r, s, nodes[k], nodes[k + 1], 1.0);
454}
455
456/** `Network.serialRouting(nodes)` on one class of a model. */
457inline void serial_routing(Routing& P, std::size_t r, const std::vector<std::size_t>& nodes) {
458 serial_routing(P, r, r, nodes);
459}
460
461/** The same chain closed into a cycle, which is how a closed model circulates. */
462inline void cyclic_routing(Routing& P, std::size_t r, const std::vector<std::size_t>& nodes) {
463 serial_routing(P, r, r, nodes);
464 if (nodes.size() > 1) P.set(r, r, nodes.back(), nodes.front(), 1.0);
465}
466
467} // namespace line
468
469#endif // LINE_LANG_QN_NODES_H
void set_miss_class(std::size_t cls, std::size_t miss)
setMissClass(jobclass, missclass).
Definition nodes.h:251
Cache(NetworkModel &m, const std::string &nm, const qn::CacheParam< double > &par)
Definition nodes.h:237
void set_read(std::size_t cls, const lang::Distrib< double > &d)
setRead(jobclass, Zipf(s, n)) or setRead(jobclass, DiscreteSampler(p)).
Definition nodes.h:247
void set_hit_class(std::size_t cls, std::size_t hit)
setHitClass(jobclass, hitclass).
Definition nodes.h:249
void set_read(std::size_t cls, const std::vector< double > &pmf)
setRead(jobclass, popularity): a pmf over the item ranks 1..nitems.
Definition nodes.h:245
void set_item_read_classes(const std::vector< std::size_t > &read_classes, const std::vector< std::size_t > &hit_classes)
setItemReadClasses(read_classes, hit_classes), one entry per item.
Definition nodes.h:240
void set_class_switching_matrix(const Matrix< double > &C)
setClassSwitchingMatrix(C).
Definition nodes.h:211
ClassSwitch(NetworkModel &m, const std::string &nm, const Matrix< double > &C)
Definition nodes.h:206
ClosedClass(NetworkModel &m, const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
Definition nodes.h:407
Delay(NetworkModel &m, const std::string &nm)
Definition nodes.h:156
Fork(NetworkModel &m, const std::string &nm, double tasks_per_link=1.0)
Definition nodes.h:219
A job class: the index it was given, and the model that owns it.
Definition nodes.h:385
void set_completes(bool flag)
completes = flag: whether passing the reference station completes the chain's cycle.
Definition nodes.h:394
std::string name_
Definition nodes.h:401
std::size_t idx_
Definition nodes.h:400
NetworkModel * model_
Definition nodes.h:399
JobClass(NetworkModel &m, std::size_t idx, const std::string &nm)
Definition nodes.h:397
const std::string & get_name() const
getName().
Definition nodes.h:390
std::size_t get_index() const
get_index(): the 1-based class index.
Definition nodes.h:388
void set_strategy(lang::JoinStrategy strategy, double quorum=0.0)
setStrategy(strategy, quorum).
Definition nodes.h:229
Join(NetworkModel &m, const std::string &nm, std::size_t fork_node)
Definition nodes.h:226
A node of the model: the index it was given, and the model that owns it.
Definition nodes.h:59
Node(NetworkModel &m, std::size_t idx, const std::string &nm)
Definition nodes.h:86
std::size_t idx_
Definition nodes.h:89
std::string name_
Definition nodes.h:90
void set_routing(std::size_t cls, lang::RoutingStrategy rs)
setRouting(class, strategy).
Definition nodes.h:77
NetworkModel & model() const
The model this node belongs to.
Definition nodes.h:66
NetworkModel * model_
Definition nodes.h:88
std::size_t get_index() const
get_index(): the 1-based node index the builder assigned.
Definition nodes.h:62
void set_routing_weights(std::size_t cls, const std::map< std::size_t, double > &weights)
setRoutingWeight(class, weights): the WRROBIN share per destination.
Definition nodes.h:81
const std::string & get_name() const
getName().
Definition nodes.h:64
OpenClass(NetworkModel &m, const std::string &nm, int prio=0)
Definition nodes.h:415
Place(model, name): a Petri-net place.
Definition nodes.h:255
void set_departure_discipline(std::size_t cls, lang::DepartureDiscipline rule)
setDepartureDiscipline(class, rule): how a served token leaves the depository.
Definition nodes.h:268
void set_fluid_capacity(double cap)
setFluidCapacity(B): the level ceiling, Inf when unbounded.
Definition nodes.h:280
void set_fluid_level(double level)
setFluidLevel(x0): the initial level.
Definition nodes.h:284
double get_fluid_level() const
getFluidLevel().
Definition nodes.h:286
void set_initial_marking(const std::vector< double > &tokens)
setInitialMarking(tokens).
Definition nodes.h:272
Place(NetworkModel &m, const std::string &nm)
Definition nodes.h:257
bool is_fluid() const
isFluid().
Definition nodes.h:278
Place(NetworkModel &m, const std::string &nm, lang::SchedStrategy sched)
Place(model, name, schedStrategy): a place with an EMBEDDED QUEUE.
Definition nodes.h:265
double get_fluid_capacity() const
getFluidCapacity().
Definition nodes.h:282
void set_fluid(bool flag=true)
setFluid(flag): a FLUID place of an FSPN, holding one real level instead of tokens.
Definition nodes.h:276
Queue(NetworkModel &m, const std::string &nm, lang::SchedStrategy sched=lang::SchedStrategy::FCFS)
Definition nodes.h:148
Router(NetworkModel &m, const std::string &nm)
Definition nodes.h:200
SelfLoopingClass(NetworkModel &m, const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
Definition nodes.h:422
Sink(NetworkModel &m, const std::string &nm)
Definition nodes.h:194
void set_arrival_batch(std::size_t cls, const Dist &d)
setArrivalBatch(class, batchSizeDist).
Definition nodes.h:166
void set_arrival(std::size_t cls, const Dist &d)
setArrival(class, distribution).
Definition nodes.h:164
void set_marked_arrival(const Dist &d, const std::vector< std::size_t > &classes)
setMarkedArrival(process, classes): bind a MARKED arrival process, one class per mark.
Definition nodes.h:184
Source(NetworkModel &m, const std::string &nm)
Definition nodes.h:162
void add_server_type(const qn::Station< double >::ServerType &stype)
addServerType(type): one pool of a heterogeneous station.
Definition nodes.h:135
void set_breakdown(const Dist &failure, const Dist &repair)
setBreakdown(failure, repair).
Definition nodes.h:131
void set_polling_type(lang::PollingType rule, int par=0)
setPollingType(type, k).
Definition nodes.h:119
Station(NetworkModel &m, std::size_t idx, const std::string &nm)
Definition nodes.h:142
void set_switchover(std::size_t from_cls, std::size_t to_cls, const Dist &so)
setSwitchover(fromClass, toClass, distribution).
Definition nodes.h:127
void set_capacity(double k)
setCapacity(k), the K of Kendall's notation.
Definition nodes.h:101
void set_service(std::size_t cls, const Dist &d)
setService(class, distribution).
Definition nodes.h:97
void set_sched_param(std::size_t cls, double weight)
setSchedParam(class, weight): the DPS/GPS share.
Definition nodes.h:111
void set_class_capacity(std::size_t cls, double k)
setClassCapacity(class, k).
Definition nodes.h:103
std::size_t get_station_index() const
getStationIndex(): the 1-based station index, distinct from the node one.
Definition nodes.h:139
void set_drop_rule(std::size_t cls, lang::DropStrategy rule)
setDropRule(class, rule).
Definition nodes.h:107
void set_number_of_servers(double n)
setNumberOfServers(n).
Definition nodes.h:99
void set_load_dependence(const std::vector< double > &alpha)
setLoadDependence(alpha).
Definition nodes.h:115
void set_switchover(std::size_t cls, const Dist &so)
setSwitchover(class, distribution).
Definition nodes.h:123
void set_firing_weights(std::size_t mode, double w)
setFiringWeights(mode, weight): the share among simultaneously enabled modes.
Definition nodes.h:330
void set_fluid_rate(std::size_t mode, const Place &place, double rate)
setFluidRate(mode, place, rate): flow per running server into (> 0) or out of (< 0) a fluid place.
Definition nodes.h:339
void set_fluid_flow_dependence(std::size_t mode, const Place &place, const std::function< double(const std::vector< double > &)> &phi, const std::vector< Place > &read=std::vector< Place >())
setFluidFlowDependence(mode, place, phi[, readPlaces]): the flow on the fluid place becomes k * rate ...
Definition nodes.h:360
void set_fluid_impulse(std::size_t mode, const Place &place, double delta)
setFluidImpulse(mode, place, delta): the level jump on every firing of the mode.
Definition nodes.h:347
void set_fluid_rate_dependence(std::size_t mode, const Place &place, const std::function< double(double)> &h)
setFluidRateDependence(mode, place, h): h(level) scales the firing rate of a timed Exp mode.
Definition nodes.h:351
Transition(NetworkModel &m, const std::string &nm)
Definition nodes.h:306
void set_number_of_servers(std::size_t mode, double n)
setNumberOfServers(mode, n); GlobalConstants::MaxInt is infinite.
Definition nodes.h:322
void set_firing_rate_dependence(std::size_t mode, const std::function< double(const std::vector< double > &)> &g)
setFiringRateDependence(mode, g): g(marking) scales the firing rate.
Definition nodes.h:334
void set_firing_outcome(std::size_t mode, const JobClass &cls, const Node &dest, double tokens)
setFiringOutcome(mode, class, node, tokens); the node may be a Sink.
Definition nodes.h:441
bool has_fluid_arcs() const
hasFluidArcs().
Definition nodes.h:368
void set_timing_strategy(std::size_t mode, lang::TimingStrategy ts)
setTimingStrategy(mode, strategy): TIMED or IMMEDIATE.
Definition nodes.h:318
void set_inhibiting_conditions(std::size_t mode, const JobClass &cls, const Place &place, double tokens)
setInhibitingConditions(mode, class, place, tokens); absent means never.
Definition nodes.h:436
void set_fluid_guard(std::size_t mode, const Place &place, const std::string &op, double threshold)
setFluidGuard(mode, place, op, threshold): op ">=" or "<="; an empty op removes the guard.
Definition nodes.h:343
void set_firing_priorities(std::size_t mode, double prio)
setFiringPriorities(mode, priority).
Definition nodes.h:326
std::size_t add_mode(const std::string &nm)
addMode(name): the new mode's 1-based index.
Definition nodes.h:312
void set_distribution(std::size_t mode, const Dist &d)
setDistribution(mode, dist): the mode's firing law.
Definition nodes.h:314
void set_enabling_conditions(std::size_t mode, const JobClass &cls, const Place &place, double tokens)
setEnablingConditions(mode, class, place, tokens).
Definition nodes.h:431
Transition(NetworkModel &m, const std::string &nm, const qn::TransitionParam< double > &par)
The all-at-once form, for a caller that already holds a finished block.
Definition nodes.h:308
A queueing network under construction.
void set_drop_rule(std::size_t node, std::size_t cls, DropStrategy rule)
station.setDropRule(class, rule).
void set_departure_discipline(std::size_t node, std::size_t cls, lang::DepartureDiscipline rule)
Place.setDepartureDiscipline(class, rule).
void set_load_dependence(std::size_t node, const std::vector< T > &alpha)
station.setLoadDependence(alpha): the rate multiplier at population 1, 2, ... The vector is indexed f...
void set_mode_fluid_impulse(std::size_t node, std::size_t mode, std::size_t place, double delta)
Transition.setFluidImpulse(mode, place, delta): every firing of the mode moves the level of the fluid...
void set_class_capacity(std::size_t node, std::size_t cls, double k)
station.setChainCapacity(class, k).
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 ...
void set_arrival_batch(std::size_t node, std::size_t cls, const Distrib< T > &dist)
Source.setArrivalBatch(class, dist): the batch-size law released at each arrival epoch.
double get_fluid_level(std::size_t node)
void set_cache_read(std::size_t cache_node, std::size_t r, const std::vector< T > &pmf)
Cache.setRead(jobclass, popularity): class r (1-based) reads the cache, drawing items from the pmf pm...
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.
void set_cache_miss_class(std::size_t cache_node, std::size_t r, std::size_t m)
Cache.setMissClass(jobclass, missclass): a class-r read that misses leaves as class m.
void set_mode_fluid_dependence(std::size_t node, std::size_t mode, std::size_t place, const std::function< double(double)> &h)
Transition.setFluidRateDependence(mode, place, h): the firing rate of a TIMED, exponential mode is mu...
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.
bool is_place_fluid(std::size_t node)
Place.isFluid(), getFluidCapacity() and getFluidLevel().
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_mode_fluid_rate(std::size_t node, std::size_t mode, std::size_t place, double rate)
Transition.setFluidRate(mode, place, rate): the FSPN flow of a TIMED mode into (rate > 0) or out of (...
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_number_of_servers(std::size_t node, double n)
queue.setNumberOfServers(n).
bool has_fluid_arcs(std::size_t node) const
Transition.hasFluidArcs(): any mode declares a flow, guard, impulse or fluid rate dependence.
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.
void set_class_completes(std::size_t cls, bool flag)
jobclass.completes = flag: whether a passage through the reference station counts as a completion.
void set_class_switch_matrix(std::size_t node, const Matrix< T > &C)
Install the switching matrix of a ClassSwitch created without one.
void set_routing(std::size_t node, std::size_t cls, RoutingStrategy rs)
node.setRouting(class, strategy).
void set_join_strategy(std::size_t node, lang::JoinStrategy strategy, double quorum=0.0)
Join.setStrategy(...): STD waits for every sibling, PARTIAL for a quorum.
void set_fluid_capacity(std::size_t node, double cap)
Place.setFluidCapacity(B): the level ceiling of a fluid place, Inf when unbounded.
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.
void set_marked_classes(std::size_t node, const std::vector< std::size_t > &classes)
Source.markedClasses: the 1-based class carried by each mark of an MMAP.
void set_sched_param(std::size_t node, std::size_t cls, const T &weight)
The DPS / GPS weight of a class at a station.
void set_firing_priority(std::size_t node, std::size_t mode, double prio)
Transition.setFiringPriorities(mode, priority).
void set_fluid_level(std::size_t node, double level)
Place.setFluidLevel(x0): the initial level of a fluid place.
void set_routing_weights(std::size_t node, std::size_t cls, const std::map< std::size_t, double > &weights)
The per-destination weights of a WRROBIN dispatcher, per (node, class).
void set_mode_fluid_flow_dependence(std::size_t node, std::size_t mode, std::size_t place, const std::function< double(const std::vector< double > &)> &phi, const std::vector< std::size_t > &read=std::vector< std::size_t >())
Transition.setFluidFlowDependence(mode, place, phi, readPlaces): the flow of the mode into or out of ...
void set_capacity(std::size_t node, double k)
station.setCapacity(k), the K of Kendall's notation.
void set_switchover(std::size_t node, std::size_t cls, const Distrib< T > &so)
Queue.setSwitchover(jobclass, distrib): the switchover time of a class.
void set_cache_hit_class(std::size_t cache_node, std::size_t r, std::size_t h)
Cache.setHitClass(jobclass, hitclass): a class-r read that hits leaves as class h.
void set_place_fluid(std::size_t node, bool fluid)
Place.setFluid(flag): the place holds one real level in [0, fluid capacity] instead of tokens,...
void add_server_type(std::size_t node, const typename Station< T >::ServerType &stype)
Queue.addServerType(...): one heterogeneous server pool of the station.
void set_service(std::size_t node, std::size_t cls, const Distrib< T > &d)
station.setService(class, dist).
void set_breakdown(std::size_t node, const Distrib< T > &failure, const Distrib< T > &repair, const std::vector< Distrib< T > > &down_service=std::vector< Distrib< T > >())
Queue.setBreakdown(failure, repair, downService): the server alternates up and down on the two clocks...
void set_item_read_classes(std::size_t cache_node, const std::vector< std::size_t > &read_classes, const std::vector< std::size_t > &hit_classes)
Cache.setItemReadClasses(readClasses, hitClasses): declare that read_classes[i] is the request stream...
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 station_index(std::size_t node) const
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.
void set_mode_fluid_guard(std::size_t node, std::size_t mode, std::size_t place, const std::string &op, double threshold)
Transition.setFluidGuard(mode, place, op, threshold): the mode is enabled only while the level of the...
double get_fluid_capacity(std::size_t node)
void set_polling_type(std::size_t node, lang::PollingType rule, int par=0)
Queue.setPollingType(rule, par): the polling discipline of a POLLING station, identical across all cl...
The routing matrix a model script fills in, MATLAB's P cell array.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
Definition lang_types.h:185
DropStrategy
Blocking and loss rules, with the values of MATLAB DropStrategy.
Definition lang_types.h:431
TimingStrategy
SPN transition timing, with the values of MATLAB TimingStrategy.
Definition lang_types.h:368
JoinStrategy
Join rules, with the values of MATLAB JoinStrategy.
Definition lang_types.h:468
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
Definition lang_types.h:396
DepartureDiscipline
When a Place releases a served token, MATLAB DepartureDiscipline.
Definition lang_types.h:465
PollingType
Polling service disciplines, with the values of MATLAB PollingType.
Definition lang_types.h:377
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
lang::Distrib< double > Dist
Definition nodes.h:54
qn::Network< double > NetworkModel
Definition nodes.h:52
void cyclic_routing(Routing &P, std::size_t r, const std::vector< std::size_t > &nodes)
The same chain closed into a cycle, which is how a closed model circulates.
Definition nodes.h:462
qn::RoutingMatrix< double > Routing
Definition nodes.h:53
void serial_routing(Routing &P, std::size_t r, std::size_t s, const std::vector< std::size_t > &nodes)
Network.serialRouting(nodes) for one class pair: 1 -> 2 -> ... -> n.
Definition nodes.h:451
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
The parameters of a Cache node, MATLAB's sn.nodeparam{ind} for a Cache.
A heterogeneous server pool: count servers that serve only compatible classes, each with its own serv...
The parameters of a Transition node: MATLAB sn.nodeparam{ind} for an SPN transition,...