make jaccard-geodist the default statsimi classifier

This commit is contained in:
Patrick Brosi 2022-01-31 23:44:53 +01:00
parent cdbfb0966d
commit 647a596dea
5 changed files with 40 additions and 2 deletions

View file

@ -7,7 +7,7 @@
routing_transition_penalty_fac: 0.0083 routing_transition_penalty_fac: 0.0083
routing_station_move_penalty_fac: 0.002 routing_station_move_penalty_fac: 0.002
station_similarity_classification_method: jaccard station_similarity_classification_method: jaccard-geodist
# Regular expressions and station comparision is # Regular expressions and station comparision is
# always case insensitive! # always case insensitive!

View file

@ -61,6 +61,7 @@ using pfaedle::router::RouterImpl;
using pfaedle::router::ShapeBuilder; using pfaedle::router::ShapeBuilder;
using pfaedle::router::Stats; using pfaedle::router::Stats;
using pfaedle::statsimiclassifier::JaccardClassifier; using pfaedle::statsimiclassifier::JaccardClassifier;
using pfaedle::statsimiclassifier::JaccardGeodistClassifier;
using pfaedle::statsimiclassifier::StatsimiClassifier; using pfaedle::statsimiclassifier::StatsimiClassifier;
using pfaedle::statsimiclassifier::BTSClassifier; using pfaedle::statsimiclassifier::BTSClassifier;
using pfaedle::statsimiclassifier::EDClassifier; using pfaedle::statsimiclassifier::EDClassifier;
@ -288,6 +289,8 @@ int main(int argc, char** argv) {
statsimiClassifier = new BTSClassifier(); statsimiClassifier = new BTSClassifier();
} else if (motCfg.routingOpts.statsimiMethod == "jaccard") { } else if (motCfg.routingOpts.statsimiMethod == "jaccard") {
statsimiClassifier = new JaccardClassifier(); statsimiClassifier = new JaccardClassifier();
} else if (motCfg.routingOpts.statsimiMethod == "jaccard-geodist") {
statsimiClassifier = new JaccardGeodistClassifier();
} else if (motCfg.routingOpts.statsimiMethod == "ed") { } else if (motCfg.routingOpts.statsimiMethod == "ed") {
statsimiClassifier = new EDClassifier(); statsimiClassifier = new EDClassifier();
} else if (motCfg.routingOpts.statsimiMethod == "ped") { } else if (motCfg.routingOpts.statsimiMethod == "ped") {

View file

@ -65,7 +65,7 @@ void MotConfigReader::parse(const std::vector<std::string>& paths,
cfg.routingOpts.statsimiMethod = cfg.routingOpts.statsimiMethod =
p.getStr(secStr, "station_similarity_classification_method"); p.getStr(secStr, "station_similarity_classification_method");
} else { } else {
cfg.routingOpts.statsimiMethod = "bts"; cfg.routingOpts.statsimiMethod = "jaccard-geodist";
} }
if (p.hasKey(secStr, "routing_use_stations")) { if (p.hasKey(secStr, "routing_use_stations")) {

View file

@ -12,8 +12,35 @@
using pfaedle::statsimiclassifier::BTSClassifier; using pfaedle::statsimiclassifier::BTSClassifier;
using pfaedle::statsimiclassifier::EDClassifier; using pfaedle::statsimiclassifier::EDClassifier;
using pfaedle::statsimiclassifier::JaccardClassifier; using pfaedle::statsimiclassifier::JaccardClassifier;
using pfaedle::statsimiclassifier::JaccardGeodistClassifier;
using pfaedle::statsimiclassifier::PEDClassifier; using pfaedle::statsimiclassifier::PEDClassifier;
// _____________________________________________________________________________
bool JaccardGeodistClassifier::similar(const std::string& nameA,
const POINT& posA,
const std::string& nameB,
const POINT& posB) const {
const double THRES_M =
0.00815467271246994481; // ln 2/85 from statsimi evaluation
const double THRES_JACC = .5; // from statsimi evaluation
const double m = exp(-THRES_M * util::geo::haversine(posA, posB));
double jacc = util::jaccardSimi(nameA, nameB);
if (jacc > THRES_JACC)
jacc = .5 + (jacc - THRES_JACC) / (2.0 * (1.0 - THRES_JACC));
else
jacc = jacc / (2.0 * THRES_JACC);
return (m + jacc) / 2.0;
}
// _____________________________________________________________________________
bool JaccardGeodistClassifier::similar(const std::string& nameA,
const std::string& nameB) const {
return util::jaccardSimi(nameA, nameB) > 0.45; // 0.45 from statsimi paper
}
// _____________________________________________________________________________ // _____________________________________________________________________________
bool JaccardClassifier::similar(const std::string& nameA, const POINT& posA, bool JaccardClassifier::similar(const std::string& nameA, const POINT& posA,
const std::string& nameB, const std::string& nameB,

View file

@ -30,6 +30,14 @@ class JaccardClassifier : public StatsimiClassifier {
const std::string& nameB) const; const std::string& nameB) const;
}; };
class JaccardGeodistClassifier : public StatsimiClassifier {
public:
virtual bool similar(const std::string& nameA, const POINT& posA,
const std::string& nameB, const POINT& posB) const;
virtual bool similar(const std::string& nameA,
const std::string& nameB) const;
};
class BTSClassifier : public StatsimiClassifier { class BTSClassifier : public StatsimiClassifier {
public: public:
virtual bool similar(const std::string& nameA, const POINT& posA, virtual bool similar(const std::string& nameA, const POINT& posA,