67 const std::vector<T>& Z,
int terms) {
69 "pfqn_panacea requires transcendental arithmetic (asymptotic expansion of log G)");
72 const std::size_t q = L.
rows(), p = L.
cols();
73 if (N.size() != p)
throw InputError(
"pfqn_panacea: L and N disagree on the class count");
74 if (terms < 1 || terms > 3)
75 throw InputError(
"pfqn_panacea: the terms parameter must be 1, 2 or 3");
77 std::vector<T> Zv = Z;
79 if (Zv.size() != p)
throw InputError(
"pfqn_panacea: Z has the wrong length");
85 bool anyDemand =
false;
86 for (std::size_t i = 0; i < q; ++i)
87 for (std::size_t r = 0; r < p; ++r)
88 if (L(i, r) != zero) anyDemand =
true;
89 if (q == 0 || !anyDemand) {
91 for (std::size_t r = 0; r < p; ++r) {
104 for (std::size_t i = 0; i < q; ++i)
105 for (std::size_t s = 0; s < p; ++s) {
106 if (Zv[s] == zero)
throw InputError(
"pfqn_panacea: zero think time");
107 rr(i, s) = T(L(i, s) / Zv[s]);
108 if (rr(i, s) > zero) {
109 const T inv = T(one / rr(i, s));
110 if (first || inv > invmax) {
116 if (first)
throw InputError(
"pfqn_panacea: no positive demand ratio");
119 std::vector<T> beta(p);
122 for (std::size_t i = 0; i < q; ++i)
123 for (std::size_t s = 0; s < p; ++s) gamma(i, s) = T(rr(i, s) * Nt);
124 std::vector<T> alpha(q);
125 for (std::size_t i = 0; i < q; ++i) {
137 for (std::size_t i = 0; i < q; ++i)
138 for (std::size_t s = 0; s < p; ++s) gt(i, s) = T(gamma(i, s) / alpha[i]);
145 for (std::size_t j = 0; j < p; ++j) {
146 std::vector<int> m(p, 0);
148 A1 -= beta[j] *
pfqn_ca(gt, m, noZ).G;
150 I.push_back(T(A1 / Nt));
154 for (std::size_t j = 0; j < p; ++j) {
155 std::vector<int> m(p, 0);
161 for (std::size_t k = 0; k < p; ++k) {
162 if (k == j)
continue;
169 I.push_back(T(A2 / T(Nt * Nt)));
173 for (
const T& v : I) Isum += v;
174 if (Isum <= zero)
throw NumericError(
"pfqn_panacea: non-positive asymptotic series");
176 for (std::size_t s = 0; s < p; ++s) {
181 for (std::size_t i = 0; i < q; ++i) lG -= log(alpha[i]);
NcResult< T > pfqn_ca(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z)
Convolution algorithm for the exact normalizing constant of a closed product-form network (Buzen 1973...
PanaceaResult< T > pfqn_panacea(const Matrix< T > &L, const std::vector< int > &N, const std::vector< T > &Z, int terms)
PANACEA normal-usage asymptotic expansion of the normalizing constant (Ramakrishnan and Mitra,...