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};
245
246/** `Place(model, name)`: a Petri-net place. */
247class Place : public Station {
248 public:
249 Place(NetworkModel& m, const std::string& nm) : Station(m, m.add_place(nm), nm) {}
250 /**
251 * `Place(model, name, schedStrategy)`: a place with an EMBEDDED QUEUE.
252 *
253 * The place becomes a queueing place once `set_service` gives it a law, as
254 * `Place.setService` does in MATLAB; until then the discipline is declared
255 * and unused and the place behaves as an ordinary one.
256 */
257 Place(NetworkModel& m, const std::string& nm, lang::SchedStrategy sched)
258 : Station(m, m.add_place(nm, sched), nm) {}
259 /** `setDepartureDiscipline(class, rule)`: how a served token leaves the depository. */
262 }
263 /** `setInitialMarking(tokens)`. */
264 void set_initial_marking(const std::vector<double>& tokens) {
266 }
267};
268
269/**
270 * `Transition(model, name)`: a Petri-net transition, with its modes declared
271 * after it as MATLAB, the JAR and Python declare theirs.
272 *
273 * Transition t1(model, "T1");
274 * const std::size_t mode1 = t1.add_mode("Mode1");
275 * t1.set_distribution(mode1, Exp(2.0));
276 * t1.set_enabling_conditions(mode1, c1, p1, 2);
277 * t1.set_firing_outcome(mode1, c1, p2, 2);
278 *
279 * THE ARCS TAKE HANDLES, not indices: a `Place` where a place is meant and a
280 * `JobClass` where a class is meant, so mixing the two is a compile error.
281 * Both convert to `std::size_t`, which is exactly what made them
282 * interchangeable at a call site written against the index API.
283 */
284class Transition : public Node {
285 public:
286 Transition(NetworkModel& m, const std::string& nm) : Node(m, m.add_transition(nm), nm) {}
287 /** The all-at-once form, for a caller that already holds a finished block. */
288 Transition(NetworkModel& m, const std::string& nm, const qn::TransitionParam<double>& par)
289 : Node(m, m.add_transition(nm, par), nm) {}
290
291 /** `addMode(name)`: the new mode's 1-based index. */
292 std::size_t add_mode(const std::string& nm) { return model_->add_mode(idx_, nm); }
293 /** `setDistribution(mode, dist)`: the mode's firing law. */
294 void set_distribution(std::size_t mode, const Dist& d) {
296 }
297 /** `setTimingStrategy(mode, strategy)`: TIMED or IMMEDIATE. */
298 void set_timing_strategy(std::size_t mode, lang::TimingStrategy ts) {
299 model_->set_mode_timing(idx_, mode, ts);
300 }
301 /** `setNumberOfServers(mode, n)`; `GlobalConstants::MaxInt` is infinite. */
302 void set_number_of_servers(std::size_t mode, double n) {
303 model_->set_mode_servers(idx_, mode, n);
304 }
305 /** `setFiringPriorities(mode, priority)`. */
306 void set_firing_priorities(std::size_t mode, double prio) {
307 model_->set_firing_priority(idx_, mode, prio);
308 }
309 /** `setFiringWeights(mode, weight)`: the share among simultaneously enabled modes. */
310 void set_firing_weights(std::size_t mode, double w) {
311 model_->set_firing_weight(idx_, mode, w);
312 }
313 /** `setFiringRateDependence(mode, g)`: g(marking) scales the firing rate. */
315 std::size_t mode, const std::function<double(const std::vector<double>&)>& g) {
317 }
318 /** `setEnablingConditions(mode, class, place, tokens)`. */
319 void set_enabling_conditions(std::size_t mode, const JobClass& cls, const Place& place,
320 double tokens);
321 /** `setInhibitingConditions(mode, class, place, tokens)`; absent means never. */
322 void set_inhibiting_conditions(std::size_t mode, const JobClass& cls, const Place& place,
323 double tokens);
324 /** `setFiringOutcome(mode, class, node, tokens)`; the node may be a Sink. */
325 void set_firing_outcome(std::size_t mode, const JobClass& cls, const Node& dest,
326 double tokens);
327};
328
329// ---------------------------------------------------------------------------
330// Job classes
331// ---------------------------------------------------------------------------
332
333/** A job class: the index it was given, and the model that owns it. */
334class JobClass {
335 public:
336 /** `get_index()`: the 1-based class index. */
337 std::size_t get_index() const { return idx_; }
338 /** `getName()`. */
339 const std::string& get_name() const { return name_; }
340 /** A handle IS its index wherever one is expected. */
341 operator std::size_t() const { return idx_; }
342
343 protected:
344 JobClass(NetworkModel& m, std::size_t idx, const std::string& nm)
345 : model_(&m), idx_(idx), name_(nm) {}
347 std::size_t idx_;
348 std::string name_;
349};
350
351/** `ClosedClass(model, name, njobs, refstat, prio)`. */
352class ClosedClass : public JobClass {
353 public:
354 ClosedClass(NetworkModel& m, const std::string& nm, double njobs, std::size_t refstat_node,
355 int prio = 0)
356 : JobClass(m, m.add_closed_class(nm, njobs, refstat_node, prio), nm) {}
357};
358
359/** `OpenClass(model, name, prio)`. */
360class OpenClass : public JobClass {
361 public:
362 OpenClass(NetworkModel& m, const std::string& nm, int prio = 0)
363 : JobClass(m, m.add_open_class(nm, prio), nm) {}
364};
365
366/** `SelfLoopingClass(model, name, njobs, refstat, prio)`. */
368 public:
369 SelfLoopingClass(NetworkModel& m, const std::string& nm, double njobs,
370 std::size_t refstat_node, int prio = 0)
371 : JobClass(m, m.add_self_looping_class(nm, njobs, refstat_node, prio), nm) {}
372};
373
374
375// The three arc setters of `Transition`, defined here because they name
376// `JobClass`, which is declared below the node handles.
377
378inline void Transition::set_enabling_conditions(std::size_t mode, const JobClass& cls,
379 const Place& place, double tokens) {
380 model_->set_enabling_conditions(idx_, mode, cls.get_index(), place.get_index(), tokens);
381}
382
383inline void Transition::set_inhibiting_conditions(std::size_t mode, const JobClass& cls,
384 const Place& place, double tokens) {
385 model_->set_inhibiting_conditions(idx_, mode, cls.get_index(), place.get_index(), tokens);
386}
387
388inline void Transition::set_firing_outcome(std::size_t mode, const JobClass& cls,
389 const Node& dest, double tokens) {
390 model_->set_firing_outcome(idx_, mode, cls.get_index(), dest.get_index(), tokens);
391}
392
393// ---------------------------------------------------------------------------
394// Routing helpers, MATLAB's static Network methods
395// ---------------------------------------------------------------------------
396
397/** `Network.serialRouting(nodes)` for one class pair: 1 -> 2 -> ... -> n. */
398inline void serial_routing(Routing& P, std::size_t r, std::size_t s,
399 const std::vector<std::size_t>& nodes) {
400 for (std::size_t k = 0; k + 1 < nodes.size(); ++k) P.set(r, s, nodes[k], nodes[k + 1], 1.0);
401}
402
403/** `Network.serialRouting(nodes)` on one class of a model. */
404inline void serial_routing(Routing& P, std::size_t r, const std::vector<std::size_t>& nodes) {
405 serial_routing(P, r, r, nodes);
406}
407
408/** The same chain closed into a cycle, which is how a closed model circulates. */
409inline void cyclic_routing(Routing& P, std::size_t r, const std::vector<std::size_t>& nodes) {
410 serial_routing(P, r, r, nodes);
411 if (nodes.size() > 1) P.set(r, r, nodes.back(), nodes.front(), 1.0);
412}
413
414} // namespace line
415
416#endif // LINE_LANG_QN_NODES_H
Cache(NetworkModel &m, const std::string &nm, const qn::CacheParam< double > &par)
Definition nodes.h:237
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:354
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:334
std::string name_
Definition nodes.h:348
std::size_t idx_
Definition nodes.h:347
NetworkModel * model_
Definition nodes.h:346
JobClass(NetworkModel &m, std::size_t idx, const std::string &nm)
Definition nodes.h:344
const std::string & get_name() const
getName().
Definition nodes.h:339
std::size_t get_index() const
get_index(): the 1-based class index.
Definition nodes.h:337
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:362
Place(model, name): a Petri-net place.
Definition nodes.h:247
void set_departure_discipline(std::size_t cls, lang::DepartureDiscipline rule)
setDepartureDiscipline(class, rule): how a served token leaves the depository.
Definition nodes.h:260
void set_initial_marking(const std::vector< double > &tokens)
setInitialMarking(tokens).
Definition nodes.h:264
Place(NetworkModel &m, const std::string &nm)
Definition nodes.h:249
Place(NetworkModel &m, const std::string &nm, lang::SchedStrategy sched)
Place(model, name, schedStrategy): a place with an EMBEDDED QUEUE.
Definition nodes.h:257
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:369
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:310
Transition(NetworkModel &m, const std::string &nm)
Definition nodes.h:286
void set_number_of_servers(std::size_t mode, double n)
setNumberOfServers(mode, n); GlobalConstants::MaxInt is infinite.
Definition nodes.h:302
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:314
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:388
void set_timing_strategy(std::size_t mode, lang::TimingStrategy ts)
setTimingStrategy(mode, strategy): TIMED or IMMEDIATE.
Definition nodes.h:298
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:383
void set_firing_priorities(std::size_t mode, double prio)
setFiringPriorities(mode, priority).
Definition nodes.h:306
std::size_t add_mode(const std::string &nm)
addMode(name): the new mode's 1-based index.
Definition nodes.h:292
void set_distribution(std::size_t mode, const Dist &d)
setDistribution(mode, dist): the mode's firing law.
Definition nodes.h:294
void set_enabling_conditions(std::size_t mode, const JobClass &cls, const Place &place, double tokens)
setEnablingConditions(mode, class, place, tokens).
Definition nodes.h:378
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:288
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_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.
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_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_number_of_servers(std::size_t node, double n)
queue.setNumberOfServers(n).
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_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.
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_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_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 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_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.
void set(std::size_t r, std::size_t s, std::size_t i, std::size_t j, const T &p)
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:181
DropStrategy
Blocking and loss rules, with the values of MATLAB DropStrategy.
Definition lang_types.h:426
TimingStrategy
SPN transition timing, with the values of MATLAB TimingStrategy.
Definition lang_types.h:363
JoinStrategy
Join rules, with the values of MATLAB JoinStrategy.
Definition lang_types.h:463
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
Definition lang_types.h:391
DepartureDiscipline
When a Place releases a served token, MATLAB DepartureDiscipline.
Definition lang_types.h:460
PollingType
Polling service disciplines, with the values of MATLAB PollingType.
Definition lang_types.h:372
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:409
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:398
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
A heterogeneous server pool: count servers that serve only compatible classes, each with its own serv...
The parameters of a Cache node, MATLAB's sn.nodeparam{ind} for a Cache.