LINE Solver (C++)
Templated C++ port of the LINE queueing solver
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
27#include "line/util/error.h"
28
29namespace line {
30namespace ag {
31
32/** `SolverAG.runAnalyzer`: the converged agents as mean measures. */
33template <class T>
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
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);
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
Options of the agent-based (RCAT) solver.
A network plus its refreshed NetworkStruct.
std::vector< Station< T > > stations
stations[k-1] is the k-th station
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
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
AgResult< T > solver_ag_solve(const qn::NetworkStruct< T > &L, const AgOptions &opt)
The gates and the dispatch of SolverAG's runAnalyzer.
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.
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.
Matrix< T > sn_get_arvr_from_tput(const qn::NetworkStruct< T > &L, const Matrix< T > &TN)
A queueing network and its refreshed NetworkStruct.
The gates and the dispatch of the agent-based (RCAT) solver.
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
What the RCAT analyzer returns beyond the metrics.
Definition solver_ag.h:1287
mva::MvaSolution< T > sol
Definition solver_ag.h:1288
std::string actualmethod
Definition solver_ag.h:1289
static constexpr double FineTol
Definition lang_types.h:668
The metrics getAvg returns, after filtering.
Matrix< T > TN
throughput
Matrix< T > RN
response time, per visit
Matrix< T > UN
utilization
Matrix< T > WN
residence time, per job
std::string method
the method asked for
std::string actualmethod
the algorithm that ran
Matrix< T > QN
queue length
std::vector< T > CN
system response time per class
std::vector< T > XN
system throughput per class
Matrix< T > AN
arrival rate
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:96
std::vector< T > X
Definition mva_types.h:98
std::vector< T > C
Definition mva_types.h:98