83 const std::vector<T>& c) {
84 if (s < 1)
throw InputError(
"fj_ism_green: s must be a positive integer");
86 throw InputError(
"fj_ism_green: c must have one entry per server requirement");
89 if (!(lambda > zero) || !(mu > zero))
90 throw InputError(
"fj_ism_green: lambda and mu must be positive");
92 for (std::size_t i = 0; i < s; ++i) {
94 throw InputError(
"fj_ism_green: the server-requirement probabilities must be non-negative");
99 throw InputError(
"fj_ism_green: the server-requirement probabilities must sum to one");
106 for (
unsigned j = 1; j <= s; ++j) {
107 T mj = zero, vj = zero;
108 for (
unsigned i = 0; i < j; ++i) {
113 out.
EB += c[j - 1] * mj;
114 out.
EB2 += c[j - 1] * (vj + mj * mj);
117 out.
rho = lambda * out.
EB;
119 throw NumericError(
"fj_ism_green: unstable system, rho = lambda*E[B] >= 1");
123 const std::size_t n = s + 1;
125 for (std::size_t i = 0; i < n; ++i) {
128 for (std::size_t j = 1; j + i <= s; ++j)
129 A(i, i + j) = A(i, i + j) + lambda * c[j - 1] / den;
133 for (std::size_t i = 0; i < n; ++i)
134 for (std::size_t j = 0; j < n; ++j) M(i, j) = (i == j ? one : zero) - A(i, j);
136 std::vector<std::vector<T> > G(n, std::vector<T>(n + 1, zero));
137 for (std::size_t i = 0; i < n; ++i) {
138 for (std::size_t j = 0; j < n; ++j) G[i][j] = M(j, i);
139 G[i][n] = (i == s) ? one : zero;
141 for (std::size_t col = 0; col < n; ++col) {
142 std::size_t piv = col;
143 for (std::size_t r = col + 1; r < n; ++r) {
144 const T a = G[r][col] > zero ? G[r][col] : -G[r][col];
145 const T b = G[piv][col] > zero ? G[piv][col] : -G[piv][col];
148 if (G[piv][col] == zero)
149 throw NumericError(
"fj_ism_green: the embedded chain is singular");
151 for (std::size_t r = 0; r < n; ++r) {
152 if (r == col)
continue;
153 const T f = G[r][col] / G[col][col];
154 for (std::size_t j = col; j <= n; ++j) G[r][j] -= f * G[col][j];
158 for (std::size_t i = 0; i < n; ++i) v[i] = G[i][n] / G[i][i];
161 std::vector<T> hold(n);
162 for (std::size_t i = 0; i < n; ++i) {
164 out.
EQbar += v[i] * hold[i];
167 for (std::size_t i = 0; i < n; ++i) out.
q[i] = v[i] * hold[i] / out.
EQbar;
172 for (std::size_t i = 0; i < n; ++i) {
173 const std::size_t free = s - i;
174 for (std::size_t j = free + 1; j <= s; ++j) out.
pd += out.
q[i] * c[j - 1];
176 if (!(out.
pd > zero))
177 throw NumericError(
"fj_ism_green: no arrival can ever be delayed; the model is M/M/s");
182 for (
unsigned i = 1; i <= s; ++i) {
183 for (
unsigned k = 1; k <= i; ++k) {
184 const unsigned j = s - i + k;
185 if (j < 1 || j > s)
continue;
186 const T wgt = out.
q[i] * c[j - 1] / out.
pd;
187 if (wgt == zero)
continue;
188 T mk = zero, vk = zero;
189 for (
unsigned m = 0; m < k; ++m) {
195 out.
ED2 += wgt * (vk + mk * mk);
199 out.
EQ = out.
ED / (one - out.
rho);
201 out.
pi0 = (one - out.
rho) / (one - lambda * (out.
EB - out.
ED));
203 const T Weq = out.
ED2 / (two * out.
ED);
204 const T Wmg1 = lambda * out.
EB2 / (two * (one - out.
rho));
205 out.
W = (one - out.
pi0) * (Weq + Wmg1);
209 for (
unsigned j = 1; j <= s; ++j) out.
ES += c[j - 1] *
fj_harmonic<T>(j) / mu;
210 out.
R = out.
W + out.
ES;
FJIsmGreenResult< T > fj_ism_green(const T &lambda, const T &mu, unsigned s, const std::vector< T > &c)
Green's independent server model of simultaneous server requests.