LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
qsys_mg1_vacation.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_QSYS_QSYS_MG1_VACATION_H
6
#define LINE_API_QSYS_QSYS_MG1_VACATION_H
7
8
/**
9
* @file
10
* @ingroup api_qsys
11
* M/G/1 and M^X/G/1 exhaustive service with server vacations.
12
*
13
* Templated port of matlab/src/api/qsys/qsys_mg1_vacation.m, cross-checked
14
* against jar/src/main/java/jline/api/qsys/Qsys_mg1_vacation.java.
15
*
16
* multiple vacations (Haverkort 1998, eq. 5.38, 5.41):
17
* Wq = E[V^2]/(2E[V]) + Wq(M^X/G/1)
18
* single vacation (Haverkort 1998, eq. 5.39):
19
* Wq = lambda E[V^2] / (2 (V*(lambda) + lambda E[V])) + Wq(M^X/G/1)
20
*
21
* with lambda the batch rate, V*(lambda) the vacation LST at lambda, and
22
* Wq(M^X/G/1) the arbitrary-job wait of qsys_mxg1. W = Wq + 1/mu,
23
* U = lambda E[X]/mu, Q = lambda E[X] W. Rational in the inputs (the LST
24
* enters as a number), so exact for T = Rational.
25
*/
26
27
#include "
line/api/qsys/qsys_mxg1.h
"
28
#include "
line/num/number.h
"
29
#include "
line/util/error.h
"
30
31
namespace
line
{
32
namespace
qsys
{
33
34
/** Vacation policy: MATLAB's 'policy' option. */
35
enum class
VacationPolicy
{
Multiple
,
Single
};
36
37
/** The MATLAB name-value options of qsys_mg1_vacation. */
38
template
<
class
T>
39
struct
Mg1VacationOptions
{
40
VacationPolicy
policy
=
VacationPolicy::Multiple
;
41
T
lst
=
num_traits<T>::from_int
(0);
///< V*(lambda); read only by the single policy
42
bool
has_lst
=
false
;
///< the single policy needs lst
43
T
E_X
=
num_traits<T>::from_int
(1);
///< mean batch size
44
T
E_X2
=
num_traits<T>::from_int
(1);
///< second raw moment of the batch size
45
};
46
47
/**
48
* @brief Exhaustive-service M/G/1 (or M^X/G/1) with vacations.
49
*
50
* @param lambda (batch) arrival rate
51
* @param mu service rate of a job
52
* @param cs coefficient of variation of the service time
53
* @param EV mean vacation time (> 0)
54
* @param EV2 second raw moment of the vacation time
55
* @param opt policy, vacation LST and batch moments
56
*/
57
template
<
class
T>
58
MeanValueResult<T>
qsys_mg1_vacation
(
const
T& lambda,
const
T& mu,
const
T& cs,
const
T& EV,
59
const
T& EV2,
60
const
Mg1VacationOptions<T>
&
opt
=
Mg1VacationOptions<T>
()) {
61
const
T zero =
num_traits<T>::from_int
(0);
62
const
T one =
num_traits<T>::from_int
(1);
63
const
T two =
num_traits<T>::from_int
(2);
64
const
T tol =
num_traits<T>::from_rational
(1, 1000000000000L);
65
if
(!(EV > zero) || EV2 < EV * EV * (one - tol))
66
throw
InputError
(
ErrorKind
(
"Argument"
),
67
"qsys_mg1_vacation needs a vacation with 0 < E[V] < Inf and E[V]^2 <= E[V^2] < Inf"
);
68
const
MeanValueResult<T>
base =
qsys_mxg1
(lambda, mu, cs,
opt
.E_X,
opt
.E_X2);
69
T Wvac;
70
if
(
opt
.policy ==
VacationPolicy::Multiple
) {
71
Wvac = EV2 / (two * EV);
72
}
else
{
73
if
(!
opt
.has_lst)
74
throw
InputError
(
ErrorKind
(
"Argument"
),
75
"qsys_mg1_vacation: the single-vacation policy needs the vacation LST at the "
76
"arrival rate, V*(lambda) = E[exp(-lambda V)]"
);
77
if
(
opt
.lst < zero || !(
opt
.lst < one))
78
throw
InputError
(
ErrorKind
(
"Argument"
),
79
"qsys_mg1_vacation: the vacation LST at lambda must lie in [0,1) for a vacation "
80
"with E[V] > 0"
);
81
Wvac = lambda * EV2 / (two * (
opt
.lst + lambda * EV));
82
}
83
MeanValueResult<T>
r;
84
r.
Wq
= base.
Wq
+ Wvac;
85
r.
W
= r.
Wq
+ one / mu;
86
r.
U
= lambda *
opt
.E_X / mu;
87
r.
Q
= lambda *
opt
.E_X * r.
W
;
88
return
r;
89
}
90
91
}
// namespace qsys
92
}
// namespace line
93
94
#endif
// LINE_API_QSYS_QSYS_MG1_VACATION_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:105
error.h
The exception types the port throws.
line::opt
Definition
bisection_solver.h:31
line::qsys
Definition
qsys_bmapm1.h:58
line::qsys::qsys_mxg1
MeanValueResult< T > qsys_mxg1(const T &lambda_batch, const T &mu, const T &cs, const T &E_X, const T &E_X2)
M^X/G/1 from the first two raw moments of the batch size.
Definition
qsys_mxg1.h:56
line::qsys::qsys_mg1_vacation
MeanValueResult< T > qsys_mg1_vacation(const T &lambda, const T &mu, const T &cs, const T &EV, const T &EV2, const Mg1VacationOptions< T > &opt=Mg1VacationOptions< T >())
Exhaustive-service M/G/1 (or M^X/G/1) with vacations.
Definition
qsys_mg1_vacation.h:58
line::qsys::VacationPolicy
VacationPolicy
Vacation policy: MATLAB's 'policy' option.
Definition
qsys_mg1_vacation.h:35
line::qsys::VacationPolicy::Single
@ Single
Definition
qsys_mg1_vacation.h:35
line::qsys::VacationPolicy::Multiple
@ Multiple
Definition
qsys_mg1_vacation.h:35
line
Conservation laws of a layered queueing network, enumerated from its structure.
Definition
aoi_dist2ph.h:51
number.h
Number-type abstraction for the templated API port.
qsys_mxg1.h
M^X/G/1: the FCFS batch-Poisson queue with general service.
line::ErrorKind::ErrorKind
ErrorKind(std::string n)
Definition
error.h:39
line::num_traits
Definition
number.h:123
line::qsys::MeanValueResult
The four outputs [W, Wq, U, Q] of qsys_mxg1, qsys_mg1_vacation and qsys_mg1_breakdown.
Definition
qsys_mxg1.h:39
line::qsys::MeanValueResult::W
T W
mean response (sojourn) time of an arbitrary job
Definition
qsys_mxg1.h:40
line::qsys::MeanValueResult::Q
T Q
mean number of jobs in the system
Definition
qsys_mxg1.h:43
line::qsys::MeanValueResult::Wq
T Wq
mean time in the system and not in service
Definition
qsys_mxg1.h:41
line::qsys::MeanValueResult::U
T U
server utilization (fraction of time doing work)
Definition
qsys_mxg1.h:42
line::qsys::Mg1VacationOptions
The MATLAB name-value options of qsys_mg1_vacation.
Definition
qsys_mg1_vacation.h:39
line::qsys::Mg1VacationOptions::policy
VacationPolicy policy
Definition
qsys_mg1_vacation.h:40
line::qsys::Mg1VacationOptions::lst
T lst
V*(lambda); read only by the single policy.
Definition
qsys_mg1_vacation.h:41
line::qsys::Mg1VacationOptions::E_X
T E_X
mean batch size
Definition
qsys_mg1_vacation.h:43
line::qsys::Mg1VacationOptions::has_lst
bool has_lst
the single policy needs lst
Definition
qsys_mg1_vacation.h:42
line::qsys::Mg1VacationOptions::E_X2
T E_X2
second raw moment of the batch size
Definition
qsys_mg1_vacation.h:44
include
line
api
qsys
qsys_mg1_vacation.h
Generated by
1.18.0