LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
ag_dispatch.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_SOLVERS_AG_AG_DISPATCH_H
6
#define LINE_SOLVERS_AG_AG_DISPATCH_H
7
8
/**
9
* @file ag_dispatch.h
10
* @ingroup line_solvers
11
* @brief The `-s ag` entry point: gates, fixed point, mean measures.
12
*
13
* The AG twin of `solver_mam_run_analyzer`. It filters the same metric kinds through the
14
* same mask rules, because what a solver reports is a property of the model and
15
* not of the algorithm; everything above the filter -- which agents exist, how
16
* they couple, who evaluates them -- is SolverAG's own.
17
*/
18
19
#include <string>
20
#include <vector>
21
22
#include "
line/lang/lang_types.h
"
23
#include "
line/lang/qn/network_struct.h
"
24
#include "
line/solvers/ag/ag_types.h
"
25
#include "
line/solvers/ag/solver_ag_runner.h
"
26
#include "
line/solvers/mva/solver_mva_runner.h
"
27
#include "
line/util/error.h
"
28
29
namespace
line
{
30
namespace
ag
{
31
32
/** `SolverAG.runAnalyzer`: the converged agents as mean measures. */
33
template
<
class
T>
34
mva::AvgResult<T>
solver_ag_run_analyzer
(
const
qn::NetworkStruct<T>
& L,
const
AgOptions
&
opt
) {
35
const
std::string origmethod =
opt
.method;
36
const
AgResult<T>
d =
solver_ag_solve
(L,
opt
);
37
const
mva::MvaSolution<T>
& s = d.
sol
;
38
39
const
std::size_t M = L.
nstations
, K = L.
nclasses
;
40
std::vector<std::vector<bool>> mask(M, std::vector<bool>(K,
false
));
41
for
(std::size_t i = 0; i < M; ++i)
42
for
(std::size_t k = 0; k < K; ++k)
43
mask[i][k] =
num_traits<T>::to_double
(s.
R
(i, k)) < 10.0 *
lang::GlobalConstants::FineTol
;
44
std::vector<std::vector<bool>> srcmask(M, std::vector<bool>(K,
false
));
45
for
(std::size_t i = 0; i < M; ++i)
46
if
(L.
stations
[i].nodetype == qn::NodeType::Source)
47
for
(std::size_t k = 0; k < K; ++k) srcmask[i][k] =
true
;
48
49
mva::AvgResult<T>
out;
50
out.
QN
=
mva::filter_metric
(L, s.
Q
,
mva::MetricKind::QLen
, &mask);
51
out.
UN
=
mva::filter_metric
(L, s.
U
,
mva::MetricKind::Util
, &mask);
52
out.
RN
=
mva::filter_metric
(L, s.
R
,
mva::MetricKind::RespT
,
nullptr
);
53
out.
TN
=
mva::filter_metric
(L, s.
Tp
,
mva::MetricKind::Tput
,
nullptr
);
54
out.
WN
=
mva::filter_metric
(L,
mva::sn_get_residt_from_respt
(L, out.
RN
),
55
mva::MetricKind::ResidT
,
nullptr
);
56
out.
AN
=
mva::filter_metric
(L,
mva::sn_get_arvr_from_tput
(L, out.
TN
),
mva::MetricKind::ArvR
,
57
&srcmask);
58
out.
CN
= s.
C
;
59
out.
XN
= s.
X
;
60
// TWO FIELDS, NOT ONE: `method` is what the caller asked for and
61
// `actualmethod` is the algorithm that produced the numbers, which is the
62
// convention `solver_nc_run_analyzer` keeps and the one every banner reads. Writing
63
// the resolved name into `method` and leaving `actualmethod` EMPTY is what
64
// made the example twin print `AG (method=)` with no name at all, where the
65
// JAR records "inap" for the same solve.
66
//
67
// 'default' resolves to inap and 'exact' falls back to it, so the resolved
68
// name is reported rather than the asked-for one: 'exact' is classified
69
// globally as an exact method, and leaving the name in place would banner an
70
// iterative approximation as exact.
71
out.
method
= origmethod;
72
out.
actualmethod
= (origmethod ==
"default"
&& !d.
actualmethod
.empty() &&
73
d.
actualmethod
!=
"default"
)
74
?
"default/"
+ d.
actualmethod
75
: (origmethod ==
"exact"
? d.
actualmethod
: origmethod);
76
out.
iter
= s.
iter
;
77
return
out;
78
}
79
80
}
// namespace ag
81
}
// namespace line
82
83
#endif
// LINE_SOLVERS_AG_AG_DISPATCH_H
ag_types.h
Options of the agent-based (RCAT) solver.
line::qn::NetworkStruct
A network plus its refreshed NetworkStruct.
Definition
network_struct.h:838
line::qn::NetworkStruct::nclasses
std::size_t nclasses
Definition
network_struct.h:1074
line::qn::NetworkStruct::stations
std::vector< Station< T > > stations
stations[k-1] is the k-th station
Definition
network_struct.h:851
line::qn::NetworkStruct::nstations
std::size_t nstations
Definition
network_struct.h:1074
error.h
The exception types the port throws.
lang_types.h
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
line::ag
Definition
ag_dispatch.h:30
line::ag::solver_ag_run_analyzer
mva::AvgResult< T > solver_ag_run_analyzer(const qn::NetworkStruct< T > &L, const AgOptions &opt)
SolverAG.runAnalyzer: the converged agents as mean measures.
Definition
ag_dispatch.h:34
line::ag::solver_ag_solve
AgResult< T > solver_ag_solve(const qn::NetworkStruct< T > &L, const AgOptions &opt)
The gates and the dispatch of SolverAG's runAnalyzer.
Definition
solver_ag_runner.h:193
line::mva::sn_get_residt_from_respt
Matrix< T > sn_get_residt_from_respt(const qn::NetworkStruct< T > &L, const Matrix< T > &RN)
Port of sn_get_residt_from_respt: the per-JOB residence time.
Definition
solver_mva_runner.h:393
line::mva::filter_metric
Matrix< T > filter_metric(const qn::NetworkStruct< T > &L, const Matrix< T > &metric, MetricKind kind, const std::vector< std::vector< bool > > *zero_mask)
Port of filterMetric: what @@NetworkSolver/getAvg does between the analyzer and the caller.
Definition
solver_mva_runner.h:547
line::mva::MetricKind::ArvR
@ ArvR
Definition
solver_mva_runner.h:537
line::mva::MetricKind::Util
@ Util
Definition
solver_mva_runner.h:537
line::mva::MetricKind::Tput
@ Tput
Definition
solver_mva_runner.h:537
line::mva::MetricKind::RespT
@ RespT
Definition
solver_mva_runner.h:537
line::mva::MetricKind::ResidT
@ ResidT
Definition
solver_mva_runner.h:537
line::mva::MetricKind::QLen
@ QLen
Definition
solver_mva_runner.h:537
line::mva::sn_get_arvr_from_tput
Matrix< T > sn_get_arvr_from_tput(const qn::NetworkStruct< T > &L, const Matrix< T > &TN)
Definition
solver_mva_runner.h:480
line::opt
Definition
bisection_solver.h:31
line
Definition
aoi_dist2ph.h:52
network_struct.h
A queueing network and its refreshed NetworkStruct.
solver_ag_runner.h
The gates and the dispatch of the agent-based (RCAT) solver.
solver_mva_runner.h
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
line::ag::AgOptions
Definition
ag_types.h:49
line::ag::AgResult
What the RCAT analyzer returns beyond the metrics.
Definition
solver_ag.h:1287
line::ag::AgResult::sol
mva::MvaSolution< T > sol
Definition
solver_ag.h:1288
line::ag::AgResult::actualmethod
std::string actualmethod
Definition
solver_ag.h:1289
line::lang::GlobalConstants::FineTol
static constexpr double FineTol
Definition
lang_types.h:668
line::mva::AvgResult
The metrics getAvg returns, after filtering.
Definition
solver_mva_runner.h:56
line::mva::AvgResult::TN
Matrix< T > TN
throughput
Definition
solver_mva_runner.h:60
line::mva::AvgResult::RN
Matrix< T > RN
response time, per visit
Definition
solver_mva_runner.h:59
line::mva::AvgResult::UN
Matrix< T > UN
utilization
Definition
solver_mva_runner.h:58
line::mva::AvgResult::iter
int iter
Definition
solver_mva_runner.h:85
line::mva::AvgResult::WN
Matrix< T > WN
residence time, per job
Definition
solver_mva_runner.h:62
line::mva::AvgResult::method
std::string method
the method asked for
Definition
solver_mva_runner.h:65
line::mva::AvgResult::actualmethod
std::string actualmethod
the algorithm that ran
Definition
solver_mva_runner.h:66
line::mva::AvgResult::QN
Matrix< T > QN
queue length
Definition
solver_mva_runner.h:57
line::mva::AvgResult::CN
std::vector< T > CN
system response time per class
Definition
solver_mva_runner.h:63
line::mva::AvgResult::XN
std::vector< T > XN
system throughput per class
Definition
solver_mva_runner.h:64
line::mva::AvgResult::AN
Matrix< T > AN
arrival rate
Definition
solver_mva_runner.h:61
line::mva::MvaSolution
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition
mva_types.h:96
line::mva::MvaSolution::X
std::vector< T > X
Definition
mva_types.h:98
line::mva::MvaSolution::U
Matrix< T > U
Definition
mva_types.h:97
line::mva::MvaSolution::C
std::vector< T > C
Definition
mva_types.h:98
line::mva::MvaSolution::R
Matrix< T > R
Definition
mva_types.h:97
line::mva::MvaSolution::Tp
Matrix< T > Tp
Definition
mva_types.h:97
line::mva::MvaSolution::Q
Matrix< T > Q
Definition
mva_types.h:97
line::mva::MvaSolution::iter
int iter
Definition
mva_types.h:100
line::num_traits
Definition
number.h:111
include
line
solvers
ag
ag_dispatch.h
Generated by
1.18.0