summaryrefslogtreecommitdiff
path: root/geom_bottleneck/example/bottleneck_dist.cpp
diff options
context:
space:
mode:
authorArnur Nigmetov <a.nigmetov@gmail.com>2017-04-06 11:54:54 +0200
committerArnur Nigmetov <a.nigmetov@gmail.com>2017-04-06 11:54:54 +0200
commit478642224bca43ebe2c878159fb5b7989ed2641e (patch)
tree5238265d1f961e94ae8810a15d447cbcb1f726d1 /geom_bottleneck/example/bottleneck_dist.cpp
parent5cda650aa878a9b5929c65eb83f431e117d39811 (diff)
Heuristic for bottleneck: estimate on sampled diagram
Sample input diagrams and use the distance between samples as initial guess in binary search. Relevant variables: bottleneck_dist.cpp:10 useSamplingHeur (if false, heuristic is never applied) bottleneck_dist.cpp:11 heurThreshold (heuristic is not applid to diagrams with fewer points) TODO: add command-line parameters instead Sampling strategy: sort points by multiplicity, set cutting value to be the multiplicity where the increase of the next one is maximal and only keep points whose multiplicity is less then the cutting value
Diffstat (limited to 'geom_bottleneck/example/bottleneck_dist.cpp')
-rw-r--r--geom_bottleneck/example/bottleneck_dist.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/geom_bottleneck/example/bottleneck_dist.cpp b/geom_bottleneck/example/bottleneck_dist.cpp
index 655de44..b27bdbb 100644
--- a/geom_bottleneck/example/bottleneck_dist.cpp
+++ b/geom_bottleneck/example/bottleneck_dist.cpp
@@ -6,6 +6,11 @@
typedef std::vector<std::pair<double, double>> PairVector;
+// estimate initial guess on sampled diagram?
+constexpr bool useSamplingHeur = false;
+// if diagrams contain fewer points, don't use heuristic
+constexpr int heurThreshold = 30000;
+
int main(int argc, char* argv[])
{
if (argc < 3 ) {
@@ -29,7 +34,11 @@ int main(int argc, char* argv[])
// return approximate distance (faster)
double approxEpsilon = atof(argv[3]);
if (approxEpsilon > 0.0) {
- res = geom_bt::bottleneckDistApprox(diagramA, diagramB, approxEpsilon);
+ if (useSamplingHeur && diagramA.size() > heurThreshold && diagramB.size() > heurThreshold) {
+ res = geom_bt::bottleneckDistApproxHeur(diagramA, diagramB, approxEpsilon);
+ } else {
+ res = geom_bt::bottleneckDistApprox(diagramA, diagramB, approxEpsilon);
+ }
} else if (approxEpsilon == 0.0) {
res = geom_bt::bottleneckDistExact(diagramA, diagramB, decPrecision);
} else {