LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
sim_quest_options.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_API_SIM_SIM_QUEST_OPTIONS_H
6
#define LINE_API_SIM_SIM_QUEST_OPTIONS_H
7
8
/**
9
* @file
10
* @ingroup api_sim
11
* Options of the QUEST procedures, with the published FQUEST defaults.
12
*
13
* Port of matlab/src/api/sim/sim_quest_options.m. The defaults b0 = 50, m0 = 500,
14
* s = [32 24 16 10], beta = 0.30, eta = 0.2 and theta = 2.3 are the ones the
15
* article reports after its own experimentation: b0 = 50 gives the warmup
16
* randomness test enough power, 32 batches suffice to estimate the variance
17
* parameter while fewer than 10 make the interval unreliable, and the decaying
18
* warmup significance keeps the batch size from growing so far that truncation
19
* eats a short sample. With these values the fourth warmup iteration runs at
20
* beta*exp(-0.2*3^2.3) = 0.025.
21
*
22
* The reference also rejects unknown field names, which a struct cannot carry;
23
* what remains here is the admissibility check, and it is not cosmetic. In
24
* particular s must be STRICTLY DECREASING: sim_fquest walks it as a
25
* batch-count ladder that only ever steps down, so a non-monotone s would let a
26
* later stage re-test a batch count an earlier stage had already rejected and
27
* the loop would no longer terminate at the ladder's end.
28
*/
29
30
#include <cmath>
31
#include <cstddef>
32
#include <vector>
33
34
#include "
line/util/error.h
"
35
36
namespace
line
{
37
namespace
sim
{
38
39
/** Procedure constants shared by sim_fquest and sim_firquest. */
40
struct
QuestOptions
{
41
long
b0
= 50;
///< Initial batch count for the warmup stage
42
long
m0
= 500;
///< Initial batch size for the warmup stage
43
std::vector<long>
s
{32, 24, 16, 10};
///< Descending batch counts for the test stages
44
double
beta
= 0.30;
///< Significance level of the stage tests
45
double
eta
= 0.2;
///< Decay coefficient of the warmup significance
46
double
theta
= 2.3;
///< Decay exponent of the warmup significance
47
double
weight
= std::sqrt(12.0);
///< Constant STS weight function
48
bool
force
=
true
;
///< Deliver a heuristic interval when a test fails
49
};
50
51
/**
52
* Validates an option set and returns it.
53
*
54
* @param options the constants to check
55
* @return the same constants, once every admissibility condition holds
56
*/
57
inline
QuestOptions
sim_quest_options
(
const
QuestOptions
& options =
QuestOptions
()) {
58
QuestOptions
opt
= options;
59
if
(
opt
.b0 < 3)
throw
InputError
(
"sim_quest_options: b0 must be an integer >= 3"
);
60
if
(
opt
.m0 < 1)
throw
InputError
(
"sim_quest_options: m0 must be a positive integer"
);
61
if
(
opt
.s.empty())
62
throw
InputError
(
"sim_quest_options: s must be a nonempty vector of positive integers"
);
63
for
(std::size_t i = 0; i <
opt
.s.size(); ++i)
64
if
(
opt
.s[i] < 1)
65
throw
InputError
(
"sim_quest_options: s must be a nonempty vector of positive integers"
);
66
for
(std::size_t i = 1; i <
opt
.s.size(); ++i)
67
if
(
opt
.s[i] >=
opt
.s[i - 1])
68
throw
InputError
(
"sim_quest_options: s must be strictly decreasing"
);
69
if
(!(
opt
.beta > 0.0) || !(
opt
.beta < 1.0))
70
throw
InputError
(
"sim_quest_options: beta must be a real scalar in (0,1)"
);
71
if
(!(
opt
.eta >= 0.0))
72
throw
InputError
(
"sim_quest_options: eta must be a nonnegative real scalar"
);
73
if
(!(
opt
.theta > 0.0))
74
throw
InputError
(
"sim_quest_options: theta must be a positive real scalar"
);
75
if
(
opt
.weight == 0.0)
76
throw
InputError
(
"sim_quest_options: weight must be a nonzero real scalar"
);
77
return
opt
;
78
}
79
80
}
// namespace sim
81
}
// namespace line
82
83
#endif
// LINE_API_SIM_SIM_QUEST_OPTIONS_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
line::opt
Definition
bisection_solver.h:31
line::sim
Definition
sim_dist.h:44
line::sim::sim_quest_options
QuestOptions sim_quest_options(const QuestOptions &options=QuestOptions())
Validates an option set and returns it.
Definition
sim_quest_options.h:57
line
Definition
aoi_dist2ph.h:52
line::sim::QuestOptions
Procedure constants shared by sim_fquest and sim_firquest.
Definition
sim_quest_options.h:40
line::sim::QuestOptions::theta
double theta
Decay exponent of the warmup significance.
Definition
sim_quest_options.h:46
line::sim::QuestOptions::m0
long m0
Initial batch size for the warmup stage.
Definition
sim_quest_options.h:42
line::sim::QuestOptions::s
std::vector< long > s
Descending batch counts for the test stages.
Definition
sim_quest_options.h:43
line::sim::QuestOptions::force
bool force
Deliver a heuristic interval when a test fails.
Definition
sim_quest_options.h:48
line::sim::QuestOptions::eta
double eta
Decay coefficient of the warmup significance.
Definition
sim_quest_options.h:45
line::sim::QuestOptions::weight
double weight
Constant STS weight function.
Definition
sim_quest_options.h:47
line::sim::QuestOptions::b0
long b0
Initial batch count for the warmup stage.
Definition
sim_quest_options.h:41
line::sim::QuestOptions::beta
double beta
Significance level of the stage tests.
Definition
sim_quest_options.h:44
include
line
api
sim
sim_quest_options.h
Generated by
1.18.0