55 const std::vector<T>& rt,
const std::vector<long>& rt_jobid,
56 const std::vector<std::size_t>& cls, std::size_t R) {
57 const std::size_t n = at.size();
58 if (at_jobid.size() != n || cls.size() != n)
59 throw InputError(
"infer_compute_ql_at_arrival: arrival arrays have different lengths");
60 if (rt.size() != rt_jobid.size())
61 throw InputError(
"infer_compute_ql_at_arrival: response-time arrays have different lengths");
62 for (std::size_t c : cls)
63 if (c >= R)
throw InputError(
"infer_compute_ql_at_arrival: class index out of range");
66 std::vector<T> rt_matched(n);
67 for (std::size_t i = 0; i < n; ++i) {
69 for (std::size_t k = 0; k < rt_jobid.size(); ++k)
70 if (rt_jobid[k] == at_jobid[i]) {
71 rt_matched[i] = rt[k];
77 "infer_compute_ql_at_arrival: not all arrival job ids found among the response "
82 std::vector<std::size_t> order(n);
83 for (std::size_t i = 0; i < n; ++i) order[i] = i;
84 std::stable_sort(order.begin(), order.end(),
85 [&](std::size_t a, std::size_t b) { return at[a] < at[b]; });
93 std::vector<Event> events;
94 events.reserve(2 * n);
95 for (std::size_t k = 0; k < n; ++k) {
96 const std::size_t i = order[k];
104 for (std::size_t k = 0; k < n; ++k) {
105 const std::size_t i = order[k];
107 d.time = at[i] + rt_matched[i];
114 std::stable_sort(events.begin(), events.end(), [](
const Event& x,
const Event& y) {
115 if (x.time < y.time) return true;
116 if (y.time < x.time) return false;
117 return x.type < y.type;
122 std::vector<T> state(R, zero);
124 for (
const Event& e : events) {
127 for (std::size_t c = 0; c < R; ++c) ql_sorted(e.slot, c) = state[c];
134 for (std::size_t k = 0; k < n; ++k)
135 for (std::size_t c = 0; c < R; ++c) ql(order[k], c) = ql_sorted(k, c);