LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
ag_types.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_TYPES_H
6#define LINE_SOLVERS_AG_AG_TYPES_H
7
8/**
9 * @file ag_types.h
10 * @ingroup line_solvers
11 * @brief Options of the agent-based (RCAT) solver.
12 *
13 * Beside the truncation level of an open agent, these carry the EXECUTION
14 * BACKEND of the reversed-rate fixed point. The backend decides who evaluates an
15 * agent, never what the agent evaluates to: agent k reads the rest of the model
16 * only through the scalar reversed rates x, and the sweep is Jacobi, so the
17 * agent order is immaterial and every backend walks the same iterates.
18 */
19
20#include <cstddef>
21#include <string>
22#include <vector>
23
24namespace line {
25namespace ag {
26
27/** The caller's own loop, in agent order. The reference. */
28inline const char* exec_serial() { return "serial"; }
29/**
30 * Fan the agents of a sweep out over a local thread pool.
31 *
32 * Named 'parallel', with 'para' accepted as an alias -- the same pair SolverSSA's
33 * replica analyzer answers to (`case {'para','parallel'}` in
34 * solver_ssa_analyzer.m, `m == "para" || m == "parallel"` in
35 * solver_ssa_parallel.h), so one spelling convention covers both solvers. It was
36 * called 'threads' until 2026-08-19; that name is no longer accepted, and
37 * `exec_is_parallel` is the only place either spelling is recognised.
38 */
39inline const char* exec_parallel() { return "parallel"; }
40/** The accepted alias of exec_parallel(), as SolverSSA spells it. */
41inline const char* exec_para() { return "para"; }
42/** True for either spelling of the local-thread-pool backend. */
43inline bool exec_is_parallel(const std::string& mode) {
44 return mode == exec_parallel() || mode == exec_para();
45}
46/** Partition the agents over remote ag-worker processes. */
47inline const char* exec_cluster() { return "cluster"; }
48
49struct AgOptions {
50 /** 'default', 'inap', 'inapplus', 'inapinf' or the vestigial 'exact'. */
51 std::string method = "default";
52
53 /** Convergence tolerance of the reversed-rate fixed point. */
54 double tol = 1e-4;
55
56 /** SolverOptions('AG') lowers this from the global 1000 to 100. */
57 int iter_max = 100;
58
59 /**
60 * Truncation level of an OPEN agent's queue-length dimension. A closed class
61 * uses its own population instead, so this bounds only the open agents;
62 * 'inapinf' ignores it and solves them on the infinite state space through
63 * the matrix-geometric tail.
64 */
65 std::size_t max_states = 100;
66
67 /**
68 * `options.config.nonmkvorder`: the phase budget `sn_nonmarkov_toph` spends
69 * replacing a non-Markovian service law. The reference default is 20.
70 */
71 std::size_t nonmkv_order = 20;
72
73 /** One of exec_serial(), exec_parallel() (or exec_para()), exec_cluster(). */
74 std::string exec = "serial";
75
76 /**
77 * Thread-pool size for 'parallel'; 0 means one thread per available
78 * processor. Pinned rather than derived per sweep so a run is reproducible
79 * on a machine whose load changes under it.
80 */
81 unsigned nworkers = 0;
82
83 /** Worker addresses ("host:port") for 'cluster'. */
84 std::vector<std::string> endpoints;
85
86 /**
87 * Seconds to wait on a worker before solving its agents locally instead. A
88 * lost worker is never fatal: any agent can be solved anywhere given x, so a
89 * cluster run degrades to a slower run and never to a wrong one.
90 */
91 double worker_timeout = 30.0;
92};
93
94} // namespace ag
95} // namespace line
96
97#endif // LINE_SOLVERS_AG_AG_TYPES_H
const char * exec_parallel()
Fan the agents of a sweep out over a local thread pool.
Definition ag_types.h:39
const char * exec_cluster()
Partition the agents over remote ag-worker processes.
Definition ag_types.h:47
const char * exec_para()
The accepted alias of exec_parallel(), as SolverSSA spells it.
Definition ag_types.h:41
const char * exec_serial()
The caller's own loop, in agent order.
Definition ag_types.h:28
bool exec_is_parallel(const std::string &mode)
True for either spelling of the local-thread-pool backend.
Definition ag_types.h:43
std::string exec
One of exec_serial(), exec_parallel() (or exec_para()), exec_cluster().
Definition ag_types.h:74
std::string method
'default', 'inap', 'inapplus', 'inapinf' or the vestigial 'exact'.
Definition ag_types.h:51
unsigned nworkers
Thread-pool size for 'parallel'; 0 means one thread per available processor.
Definition ag_types.h:81
int iter_max
SolverOptions('AG') lowers this from the global 1000 to 100.
Definition ag_types.h:57
std::vector< std::string > endpoints
Worker addresses ("host:port") for 'cluster'.
Definition ag_types.h:84
double worker_timeout
Seconds to wait on a worker before solving its agents locally instead.
Definition ag_types.h:91
double tol
Convergence tolerance of the reversed-rate fixed point.
Definition ag_types.h:54
std::size_t max_states
Truncation level of an OPEN agent's queue-length dimension.
Definition ag_types.h:65
std::size_t nonmkv_order
options.config.nonmkvorder: the phase budget sn_nonmarkov_toph spends replacing a non-Markovian servi...
Definition ag_types.h:71