bts classifier
This commit is contained in:
parent
749044ce97
commit
516f04b9c5
9 changed files with 219 additions and 13 deletions
|
|
@ -61,6 +61,10 @@ using pfaedle::router::RouterImpl;
|
|||
using pfaedle::router::ShapeBuilder;
|
||||
using pfaedle::router::Stats;
|
||||
using pfaedle::statsimiclassifier::JaccardClassifier;
|
||||
using pfaedle::statsimiclassifier::StatsimiClassifier;
|
||||
using pfaedle::statsimiclassifier::BTSClassifier;
|
||||
using pfaedle::statsimiclassifier::EDClassifier;
|
||||
using pfaedle::statsimiclassifier::PEDClassifier;
|
||||
|
||||
enum class RetCode {
|
||||
SUCCESS = 0,
|
||||
|
|
@ -277,7 +281,21 @@ int main(int argc, char** argv) {
|
|||
graphDimensions[filePost].second += nd->getAdjListOut().size();
|
||||
}
|
||||
|
||||
JaccardClassifier statsimiClassifier;
|
||||
StatsimiClassifier* statsimiClassifier;
|
||||
|
||||
if (motCfg.routingOpts.statsimiMethod == "bts") {
|
||||
statsimiClassifier = new BTSClassifier();
|
||||
} else if (motCfg.routingOpts.statsimiMethod == "jaccard") {
|
||||
statsimiClassifier = new JaccardClassifier();
|
||||
} else if (motCfg.routingOpts.statsimiMethod == "ed") {
|
||||
statsimiClassifier = new EDClassifier();
|
||||
} else if (motCfg.routingOpts.statsimiMethod == "ped") {
|
||||
statsimiClassifier = new PEDClassifier();
|
||||
} else {
|
||||
LOG(ERROR) << "Unknown station similarity classifier "
|
||||
<< motCfg.routingOpts.statsimiMethod;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Router* router = 0;
|
||||
|
||||
|
|
@ -303,7 +321,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
ShapeBuilder shapeBuilder(>fs[0], usedMots, motCfg, &graph, &fStops,
|
||||
&restr, &statsimiClassifier, router, cfg);
|
||||
&restr, statsimiClassifier, router, cfg);
|
||||
|
||||
pfaedle::netgraph::Graph ng;
|
||||
|
||||
|
|
@ -326,6 +344,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
if (router) delete router;
|
||||
if (statsimiClassifier) delete statsimiClassifier;
|
||||
|
||||
if (cfg.writeGraph) {
|
||||
LOG(INFO) << "Outputting graph.json...";
|
||||
|
|
|
|||
|
|
@ -61,6 +61,13 @@ void MotConfigReader::parse(const std::vector<std::string>& paths,
|
|||
cfg.routingOpts.transPenMethod = "exp";
|
||||
}
|
||||
|
||||
if (p.hasKey(secStr, "station_similarity_classification_method")) {
|
||||
cfg.routingOpts.statsimiMethod =
|
||||
p.getStr(secStr, "station_similarity_classification_method");
|
||||
} else {
|
||||
cfg.routingOpts.statsimiMethod = "bts";
|
||||
}
|
||||
|
||||
if (p.hasKey(secStr, "routing_use_stations")) {
|
||||
cfg.routingOpts.useStations = p.getBool(secStr, "routing_use_stations");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ struct RoutingOpts {
|
|||
double transitionPen;
|
||||
std::string transPenMethod;
|
||||
std::string emPenMethod;
|
||||
std::string statsimiMethod;
|
||||
};
|
||||
|
||||
// _____________________________________________________________________________
|
||||
|
|
@ -82,6 +83,7 @@ inline bool operator==(const RoutingOpts& a, const RoutingOpts& b) {
|
|||
fabs(a.nonStationPen - b.nonStationPen) < 0.01 &&
|
||||
a.transPenMethod == b.transPenMethod &&
|
||||
a.emPenMethod == b.emPenMethod &&
|
||||
a.statsimiMethod == b.statsimiMethod &&
|
||||
a.useStations == b.useStations && a.popReachEdge == b.popReachEdge &&
|
||||
a.noSelfHops == b.noSelfHops;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ using pfaedle::router::ShapeBuilder;
|
|||
using pfaedle::router::Stats;
|
||||
using pfaedle::router::TripForests;
|
||||
using pfaedle::router::TripTrie;
|
||||
using pfaedle::statsimiclassifier::JaccardClassifier;
|
||||
using pfaedle::trgraph::EdgeGrid;
|
||||
using pfaedle::trgraph::NodeGrid;
|
||||
using util::geo::latLngToWebMerc;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@
|
|||
#include "pfaedle/statsimi-classifier/StatsimiClassifier.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
||||
using pfaedle::statsimiclassifier::BTSClassifier;
|
||||
using pfaedle::statsimiclassifier::EDClassifier;
|
||||
using pfaedle::statsimiclassifier::JaccardClassifier;
|
||||
using pfaedle::statsimiclassifier::PEDClassifier;
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool JaccardClassifier::similar(const std::string& nameA, const POINT& posA,
|
||||
|
|
@ -23,8 +26,52 @@ bool JaccardClassifier::similar(const std::string& nameA, const POINT& posA,
|
|||
// _____________________________________________________________________________
|
||||
bool JaccardClassifier::similar(const std::string& nameA,
|
||||
const std::string& nameB) const {
|
||||
// hard similarity
|
||||
if (nameA == nameB) return true;
|
||||
|
||||
return util::jaccardSimi(nameA, nameB) > 0.45; // 0.45 from paper
|
||||
return util::jaccardSimi(nameA, nameB) > 0.45; // 0.45 from statsimi paper
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool BTSClassifier::similar(const std::string& nameA, const POINT& posA,
|
||||
const std::string& nameB, const POINT& posB) const {
|
||||
UNUSED(posA);
|
||||
UNUSED(posB);
|
||||
return similar(nameA, nameB);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool BTSClassifier::similar(const std::string& nameA,
|
||||
const std::string& nameB) const {
|
||||
return util::btsSimi(nameA, nameB) > 0.85; // 0.85 from statsimi paper
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool EDClassifier::similar(const std::string& nameA, const POINT& posA,
|
||||
const std::string& nameB, const POINT& posB) const {
|
||||
UNUSED(posA);
|
||||
UNUSED(posB);
|
||||
return similar(nameA, nameB);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool EDClassifier::similar(const std::string& nameA,
|
||||
const std::string& nameB) const {
|
||||
double edSimi = 1.0 - ((util::editDist(nameA, nameB) * 1.0) /
|
||||
fmax(nameA.size(), nameB.size()));
|
||||
return edSimi > 0.85; // 0.85 from statsimi paper
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool PEDClassifier::similar(const std::string& nameA, const POINT& posA,
|
||||
const std::string& nameB, const POINT& posB) const {
|
||||
UNUSED(posA);
|
||||
UNUSED(posB);
|
||||
return similar(nameA, nameB);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool PEDClassifier::similar(const std::string& nameA,
|
||||
const std::string& nameB) const {
|
||||
double a = (util::prefixEditDist(nameA, nameB) * 1.0) / (nameA.size() * 1.0);
|
||||
double b = (util::prefixEditDist(nameB, nameA) * 1.0) / (nameB.size() * 1.0);
|
||||
double pedSimi = 1.0 - fmin(a, b);
|
||||
return pedSimi > 0.875; // 0.875 average of values from statsimi paper
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace statsimiclassifier {
|
|||
|
||||
class StatsimiClassifier {
|
||||
public:
|
||||
virtual ~StatsimiClassifier() {}
|
||||
virtual bool similar(const std::string& nameA, const POINT& posA,
|
||||
const std::string& nameB, const POINT& posB) const = 0;
|
||||
|
||||
|
|
@ -29,6 +30,30 @@ class JaccardClassifier : public StatsimiClassifier {
|
|||
const std::string& nameB) const;
|
||||
};
|
||||
|
||||
class BTSClassifier : 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 EDClassifier : 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 PEDClassifier : 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;
|
||||
};
|
||||
|
||||
} // namespace statsimiclassifier
|
||||
} // namespace pfaedle
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue