Merge branch 'master' into sf-unpacked-path-struct

This commit is contained in:
Siarhei Fedartsou 2024-06-29 20:00:18 +02:00 committed by GitHub
commit 6c7da606e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 7 deletions

View File

@ -25,6 +25,7 @@
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
- Misc:
- CHANGED: Use struct instead of tuple to define UnpackedPath. [#6974](https://github.com/Project-OSRM/osrm-backend/pull/6974)
- CHANGED: Micro performance optimisation in map matching. [#6976](https://github.com/Project-OSRM/osrm-backend/pull/6976)
- CHANGED: Re-use priority queue in StaticRTree. [#6952](https://github.com/Project-OSRM/osrm-backend/pull/6952)
- CHANGED: Optimise encodePolyline function. [#6940](https://github.com/Project-OSRM/osrm-backend/pull/6940)
- CHANGED: Avoid reallocations in base64 encoding. [#6951](https://github.com/Project-OSRM/osrm-backend/pull/6951)

View File

@ -86,9 +86,9 @@ def bootstrap_confidence_interval(data, num_samples=1000, confidence_level=0.95)
mean = np.mean(means)
return mean, lower_bound, upper_bound
def calculate_confidence_interval(data):
def calculate_confidence_interval(data, min_is_best=True):
mean, lower, upper = bootstrap_confidence_interval(data)
min_value = np.min(data)
min_value = np.min(data) if min_is_best else np.max(data)
return mean, (upper - lower) / 2, min_value
@ -117,7 +117,7 @@ def main():
total_time, total_ci, total_best = calculate_confidence_interval(np.sum(all_times, axis=1))
ops_per_sec, ops_per_sec_ci, ops_per_sec_best = calculate_confidence_interval(float(all_times.shape[1]) / np.sum(all_times / 1000, axis=1))
ops_per_sec, ops_per_sec_ci, ops_per_sec_best = calculate_confidence_interval(float(all_times.shape[1]) / np.sum(all_times / 1000, axis=1), min_is_best=False)
min_time, min_ci, _ = calculate_confidence_interval(np.min(all_times, axis=1))
mean_time, mean_ci, _ = calculate_confidence_interval(np.mean(all_times, axis=1))
median_time, median_ci, _ = calculate_confidence_interval(np.median(all_times, axis=1))

View File

@ -134,6 +134,7 @@ struct ConfidenceInterval
double mean;
double confidence;
double min;
double max;
};
// Helper function to calculate the bootstrap confidence interval
@ -161,8 +162,10 @@ ConfidenceInterval confidenceInterval(const std::vector<double> &data,
double upper_bound = means[(int)((1 + confidence_level) / 2 * num_samples)];
double mean = std::accumulate(means.begin(), means.end(), 0.0) / means.size();
ConfidenceInterval ci = {
mean, (upper_bound - lower_bound) / 2, *std::min_element(data.begin(), data.end())};
ConfidenceInterval ci = {mean,
(upper_bound - lower_bound) / 2,
*std::min_element(data.begin(), data.end()),
*std::max_element(data.begin(), data.end())};
return ci;
}
@ -260,7 +263,7 @@ std::ostream &operator<<(std::ostream &os, Statistics &statistics)
ConfidenceInterval ops_ci = statistics.ops_per_sec();
os << "ops: " << ops_ci.mean << " ± " << ops_ci.confidence << " ops/s. "
<< "best: " << ops_ci.min << "ops/s." << std::endl;
<< "best: " << ops_ci.max << "ops/s." << std::endl;
os << "total: " << total_ci.mean << " ± " << total_ci.confidence << "ms. "
<< "best: " << total_ci.min << "ms." << std::endl;
os << "avg: " << mean_ci.mean << " ± " << mean_ci.confidence << "ms" << std::endl;

View File

@ -401,6 +401,7 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
auto trace_distance = 0.0;
matching.nodes.reserve(reconstructed_indices.size());
matching.indices.reserve(reconstructed_indices.size());
matching.alternatives_count.reserve(reconstructed_indices.size());
for (const auto &idx : reconstructed_indices)
{
const auto timestamp_index = idx.first;
@ -428,7 +429,7 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
matching.confidence = confidence(trace_distance, matching_distance);
sub_matchings.push_back(matching);
sub_matchings.emplace_back(std::move(matching));
sub_matching_begin = sub_matching_end;
}