69 const std::vector<int>& N) {
70 if (!oirate)
throw InputError(
"pfqn_oi_insvc: oirate must be callable");
71 const std::size_t R = N.size();
72 if (R == 0)
throw InputError(
"pfqn_oi_insvc: empty population vector");
73 std::vector<std::size_t> shp(R), stride(R, 1);
74 std::size_t total = 1;
75 for (std::size_t d = 0; d < R; ++d) {
76 if (N[d] < 0)
throw InputError(
"pfqn_oi_insvc: negative population");
77 shp[d] =
static_cast<std::size_t
>(N[d]) + 1;
79 for (std::size_t d = 1; d < R; ++d) stride[d] = stride[d - 1] * shp[d - 1];
80 for (std::size_t d = 0; d < R; ++d) total *= shp[d];
83 std::vector<std::vector<int>> subs(total, std::vector<int>(R, 0));
84 for (std::size_t i = 0; i < total; ++i) {
86 for (std::size_t d = 0; d < R; ++d) {
87 subs[i][d] =
static_cast<int>(li % shp[d]);
91 std::vector<T> muv(total, zero);
92 for (std::size_t i = 0; i < total; ++i) {
94 for (
int v : subs[i]) tot += v;
95 if (tot > 0) muv[i] = oirate(subs[i]);
98 std::vector<T> Phi(total, zero);
100 for (std::size_t i = 0; i < total; ++i) {
101 const std::vector<int>& n = subs[i];
103 for (
int v : n) tot += v;
108 const T mun = muv[i];
109 if (mun <= zero)
continue;
111 std::vector<T> sXi(R, zero);
112 for (std::size_t s = 0; s < R; ++s) {
113 if (n[s] <= 0)
continue;
114 const std::size_t j = i - stride[s];
116 for (std::size_t r = 0; r < R; ++r) sXi[r] += Xi(j, r);
118 Phi[i] = T(sPhi / mun);
119 for (std::size_t r = 0; r < R; ++r) {
122 const std::size_t j = i - stride[r];
123 if (mun > muv[j]) acc += Phi[j];
125 Xi(i, r) = T(acc / mun);
131 for (std::size_t i = 0; i < total; ++i)
133 for (std::size_t r = 0; r < R; ++r) res.
g(i, r) = T(Xi(i, r) / Phi[i]);
OiInsvcResult< T > pfqn_oi_insvc(const std::function< T(const std::vector< int > &)> &oirate, const std::vector< int > &N)
Conditional mean number of IN-SERVICE jobs per class at an order-independent station.