From 6b445b84d1ec26572e60c5cc97927263747a62a1 Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Fri, 7 Jan 2022 17:35:30 +0100 Subject: [PATCH] some updates to shapevl --- src/pfaedle/PfaedleMain.cpp | 8 +++ src/pfaedle/config/ConfigReader.cpp | 7 +-- src/pfaedle/router/Stats.h | 1 + src/shapevl/Collector.cpp | 86 +++++++++++++++++------------ src/shapevl/Collector.h | 12 ++-- 5 files changed, 68 insertions(+), 46 deletions(-) diff --git a/src/pfaedle/PfaedleMain.cpp b/src/pfaedle/PfaedleMain.cpp index e444583..6b80cb1 100644 --- a/src/pfaedle/PfaedleMain.cpp +++ b/src/pfaedle/PfaedleMain.cpp @@ -346,10 +346,15 @@ int main(int argc, char** argv) { if (cfg.writeStats) { util::json::Dict graphSizes; + double numNodesTot = 0; + double numEdgesTot = 0; + for (const auto& gd : graphDimensions) { util::json::Dict a; a["num_nodes"] = gd.second.first; a["num_edges"] = gd.second.second; + numNodesTot += gd.second.first; + numEdgesTot += gd.second.second; graphSizes[gd.first] = a; } @@ -358,7 +363,10 @@ int main(int argc, char** argv) { util::json::Dict{ {"gtfs_num_stations", gtfs[0].getStops().size()}, {"gtfs_num_trips", gtfs[0].getTrips().size()}, + {"gtfs_has_shapes", gtfs[0].getShapes().size() > 1}, {"graph_dimension", graphSizes}, + {"num_nodes_tot", numNodesTot}, + {"num_edges_tot", numEdgesTot}, {"num_tries", stats.numTries}, {"num_trie_leafs", stats.numTrieLeafs}, {"dijkstra_iters", stats.dijkstraIters}, diff --git a/src/pfaedle/config/ConfigReader.cpp b/src/pfaedle/config/ConfigReader.cpp index 1d351e6..54ed140 100644 --- a/src/pfaedle/config/ConfigReader.cpp +++ b/src/pfaedle/config/ConfigReader.cpp @@ -206,12 +206,7 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) { cfg->noHopCache = true; break; case 'v': - std::cout << "pfaedle " << VERSION_FULL << " (built " << __DATE__ << " " - << __TIME__ << " with geometry precision <" - << PFDL_PREC_STR << ">)\n" - << "(C) " << YEAR << " " << COPY << "\n" - << "Authors: " << AUTHORS << "\nGNU General Public " - "License v3.0\n"; + std::cout << "pfaedle " << VERSION_FULL << std::endl; exit(0); case 'p': printOpts = true; diff --git a/src/pfaedle/router/Stats.h b/src/pfaedle/router/Stats.h index 65bcacc..fa3659a 100644 --- a/src/pfaedle/router/Stats.h +++ b/src/pfaedle/router/Stats.h @@ -31,6 +31,7 @@ inline Stats operator+ (const Stats& c1, const Stats& c2) { Stats ret = c1; ret.totNumTrips += c2.totNumTrips; ret.numTries += c2.numTries; + ret.numTrieLeafs += c2.numTrieLeafs; ret.solveTime += c2.solveTime; ret.dijkstraIters += c2.dijkstraIters; return ret; diff --git a/src/shapevl/Collector.cpp b/src/shapevl/Collector.cpp index 610192d..67419dd 100644 --- a/src/shapevl/Collector.cpp +++ b/src/shapevl/Collector.cpp @@ -59,7 +59,7 @@ double Collector::add(const Trip* oldT, const Shape* oldS, const Trip* newT, // A "segment" is a path from station s_i to station s_{i+1} size_t unmatchedSegments; // number of unmatched segments - double unmatchedSegmentsLength; // total _acc. length of unmatched segments + double unmatchedSegmentsLength; // total _an. length of unmatched segments std::vector oldDists; LINE oldL = getWebMercLine(oldS, &oldDists); @@ -127,11 +127,13 @@ double Collector::add(const Trip* oldT, const Shape* oldS, const Trip* newT, _results.insert(Result(oldT, avgFd)); - if (AN <= 0.0001) _acc0++; - if (AN <= 0.1) _acc10++; - if (AN <= 0.2) _acc20++; - if (AN <= 0.4) _acc40++; - if (AN <= 0.8) _acc80++; + if (AN <= 0.0001) _an0++; + if (AN <= 0.05) _an5++; + if (AN <= 0.1) _an10++; + if (AN <= 0.3) _an30++; + if (AN <= 0.5) _an50++; + if (AN <= 0.7) _an70++; + if (AN <= 0.9) _an90++; LOG(VDEBUG) << "This result (" << oldT->getId() << "): A_N/N = " << unmatchedSegments << "/" << oldSegs.size() @@ -169,9 +171,9 @@ std::vector Collector::segmentize(const Trip* t, const LINE& shape, // a different position philosophy than the test data) // 6) To normalize this, we always the following approach: // a) Get the exact progression of the measurment on the shape - // b) Extract a segment of 200 meters, with the measurement progress in the middle - // c) Project the GROUND TRUTH station coordinate to this segment - // d) The result is the cutting point + // b) Extract a segment of 200 meters, with the measurement progress in + // the middle c) Project the GROUND TRUTH station coordinate to this + // segment d) The result is the cutting point // 7) If a completely wrong track was chosen, the frechet distance will still // be greater than 20 meters and AN will measure an unmatch. // 8) TODO: implement this, explain this in diss @@ -258,37 +260,39 @@ void Collector::printCsv(std::ostream* os, // _____________________________________________________________________________ double Collector::getAcc() const { - return static_cast(_acc0) / static_cast(_results.size()); + return static_cast(_an0) / static_cast(_results.size()); } // _____________________________________________________________________________ void Collector::printShortStats(std::ostream* os) const { if (_results.size()) { - (*os) << "acc-0: " - << (static_cast(_acc0) / + (*os) << (static_cast(_an0) / static_cast(_results.size())) * 100 - << " %"; - (*os) << " acc-10: " - << (static_cast(_acc10) / + << ","; + (*os) << (static_cast(_an5) / static_cast(_results.size())) * 100 - << " %"; - (*os) << " acc-20: " - << (static_cast(_acc20) / + << ","; + (*os) << (static_cast(_an10) / static_cast(_results.size())) * 100 - << " %"; - (*os) << " acc-40: " - << (static_cast(_acc40) / + << ","; + (*os) << (static_cast(_an30) / static_cast(_results.size())) * 100 - << " %"; - (*os) << " acc-80: " - << (static_cast(_acc80) / + << ","; + (*os) << (static_cast(_an50) / static_cast(_results.size())) * 100 - << " %"; + << ","; + (*os) << (static_cast(_an70) / + static_cast(_results.size())) * + 100 + << ","; + (*os) << (static_cast(_an90) / + static_cast(_results.size())) * + 100; } } @@ -313,32 +317,44 @@ void Collector::printStats(std::ostream* os) const { << " averaged avg frechet distance: " << getAvgDist() << "\n"; (*os) << "\n"; - (*os) << " acc-0: " - << (static_cast(_acc0) / + (*os) << " an-0: " + << (static_cast(_an0) / static_cast(_results.size())) * 100 << " %" << "\n"; - (*os) << " acc-10: " - << (static_cast(_acc10) / + (*os) << " an-5: " + << (static_cast(_an5) / static_cast(_results.size())) * 100 << " %" << "\n"; - (*os) << " acc-20: " - << (static_cast(_acc20) / + (*os) << " an-10: " + << (static_cast(_an10) / static_cast(_results.size())) * 100 << " %" << "\n"; - (*os) << " acc-40: " - << (static_cast(_acc40) / + (*os) << " acc-30: " + << (static_cast(_an30) / static_cast(_results.size())) * 100 << " %" << "\n"; - (*os) << " acc-80: " - << (static_cast(_acc80) / + (*os) << " acc-50: " + << (static_cast(_an50) / + static_cast(_results.size())) * + 100 + << " %" + << "\n"; + (*os) << " acc-70: " + << (static_cast(_an70) / + static_cast(_results.size())) * + 100 + << " %" + << "\n"; + (*os) << " acc-90: " + << (static_cast(_an90) / static_cast(_results.size())) * 100 << " %" diff --git a/src/shapevl/Collector.h b/src/shapevl/Collector.h index 876ccbf..14af683 100644 --- a/src/shapevl/Collector.h +++ b/src/shapevl/Collector.h @@ -77,11 +77,13 @@ class Collector { size_t _unmatchedSegSum; double _unmatchedSegLengthSum; - size_t _acc0; - size_t _acc10; - size_t _acc20; - size_t _acc40; - size_t _acc80; + size_t _an0; + size_t _an5; + size_t _an10; + size_t _an30; + size_t _an50; + size_t _an70; + size_t _an90; std::ostream* _reportOut;