LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qn_layer.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_QN_LAYER_H
6#define LINE_LANG_QN_QN_LAYER_H
7
8/**
9 * @file
10 * @ingroup line_lang
11 * One SolverLN layer: a NetworkStruct plus the LQN annotations that say which
12 * element of the layered model each station and class stands for.
13 *
14 * SCOPE. The queueing network itself, its refresh and its predicates live in
15 * `network_struct.h` and are shared with every other solver; nothing here is
16 * read by an algorithm. What a layer adds is the back-mapping SolverLN needs to
17 * write a layer's metrics onto the tasks, entries, activities and calls of the
18 * LayeredNetworkStruct it came from, which is the whole content of MATLAB's
19 * `model.attribute` fields on a layer model.
20 *
21 * The shape SolverLN builds is narrow -- a client Delay, one or more replicas
22 * of a server station, optionally a Source/Sink pair for open arrivals, and a
23 * class per LQN element, wired by a class-switching routing matrix P{r,s}(i,j)
24 * -- and `buildLayers` refuses by name when a layered model needs a construct
25 * it cannot express, rather than building a network that silently omits it.
26 */
27
28#include <array>
29#include <cstddef>
30#include <utility>
31#include <vector>
32
34
35namespace line {
36namespace qn {
37
38/**
39 * A layer network: everything a NetworkStruct holds, plus the LQN back-mapping.
40 *
41 * `clientIdx` / `serverIdx` are the two stations every layer has by
42 * construction (the callers' Delay and the served task's station); the `attr_*`
43 * vectors pair a 1-based class index with the index of the LQN element it
44 * stands for, in the LayeredNetworkStruct's own numbering.
45 *
46 * Under the SQUASHED layering (`flat`) a layer serves MANY elements at once, so
47 * `serverIdx` is no longer the answer to "which station stands for element i":
48 * `server_idx_of` is, and it is populated under both layerings so a consumer
49 * can read it without knowing which one built the layer.
50 */
51template <class T>
52class Layer : public NetworkStruct<T> {
53public:
54 std::size_t clientIdx = 0; ///< 1-based station index of the client Delay, 0 = none
55 std::size_t serverIdx = 0; ///< 1-based station index of the server
56 /** LQN element -> 1-based station index of its server here, 0 = not served here. */
57 std::vector<std::size_t> server_idx_of;
58 std::vector<std::size_t> host_stations; ///< station indices of the processor servers
59 std::vector<std::size_t> task_stations; ///< station indices of the task servers
60 bool flat = false; ///< true when built by the squashed layering
61 std::vector<std::pair<std::size_t, std::size_t>> attr_tasks; ///< (classIdx, tidx)
62 std::vector<std::pair<std::size_t, std::size_t>> attr_entries; ///< (classIdx, eidx)
63 std::vector<std::pair<std::size_t, std::size_t>> attr_activities; ///< (classIdx, aidx)
64 /** (classIdx, cidx, callerActivity, calledEntry) */
65 std::vector<std::array<std::size_t, 4>> attr_calls;
66};
67
68} // namespace qn
69} // namespace line
70
71#endif // LINE_LANG_QN_QN_LAYER_H
A layer network: everything a NetworkStruct holds, plus the LQN back-mapping.
Definition qn_layer.h:52
bool flat
true when built by the squashed layering
Definition qn_layer.h:60
std::vector< std::size_t > server_idx_of
LQN element -> 1-based station index of its server here, 0 = not served here.
Definition qn_layer.h:57
std::vector< std::pair< std::size_t, std::size_t > > attr_tasks
(classIdx, tidx)
Definition qn_layer.h:61
std::size_t clientIdx
1-based station index of the client Delay, 0 = none
Definition qn_layer.h:54
std::vector< std::size_t > host_stations
station indices of the processor servers
Definition qn_layer.h:58
std::vector< std::size_t > task_stations
station indices of the task servers
Definition qn_layer.h:59
std::vector< std::array< std::size_t, 4 > > attr_calls
(classIdx, cidx, callerActivity, calledEntry)
Definition qn_layer.h:65
std::size_t serverIdx
1-based station index of the server
Definition qn_layer.h:55
std::vector< std::pair< std::size_t, std::size_t > > attr_activities
(classIdx, aidx)
Definition qn_layer.h:63
std::vector< std::pair< std::size_t, std::size_t > > attr_entries
(classIdx, eidx)
Definition qn_layer.h:62
A network plus its refreshed NetworkStruct.
A queueing network and its refreshed NetworkStruct.