From 5d304d5720cd23ab9aa1179a147ae1e12ee17950 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Wed, 5 Jul 2017 10:01:51 -0700 Subject: Price adjustment; maxIterNum increased For high Wasserstein powers price adjustment (subtract minimal price) is needed. --- .../wasserstein/include/dnn/local/kd-tree.h | 2 +- .../wasserstein/include/dnn/local/kd-tree.hpp | 29 ++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'geom_matching/wasserstein/include/dnn') diff --git a/geom_matching/wasserstein/include/dnn/local/kd-tree.h b/geom_matching/wasserstein/include/dnn/local/kd-tree.h index 7e01072..13eaf27 100644 --- a/geom_matching/wasserstein/include/dnn/local/kd-tree.h +++ b/geom_matching/wasserstein/include/dnn/local/kd-tree.h @@ -49,7 +49,7 @@ namespace dnn void init(const Range& range); DistanceType weight(PointHandle p) { return weights_[indices_[p]]; } - void increase_weight(PointHandle p, DistanceType w); + void change_weight(PointHandle p, DistanceType w); HandleDistance find(PointHandle q) const; Result findR(PointHandle q, DistanceType r) const; // all neighbors within r diff --git a/geom_matching/wasserstein/include/dnn/local/kd-tree.hpp b/geom_matching/wasserstein/include/dnn/local/kd-tree.hpp index 6b0852c..22108aa 100644 --- a/geom_matching/wasserstein/include/dnn/local/kd-tree.hpp +++ b/geom_matching/wasserstein/include/dnn/local/kd-tree.hpp @@ -164,11 +164,15 @@ search(PointHandle q, ResultsFunctor& rf) const template void dnn::KDTree:: -increase_weight(PointHandle p, DistanceType w) +change_weight(PointHandle p, DistanceType w) { size_t idx = indices_[p]; - // weight should only increase - assert( weights_[idx] <= w ); + + if ( weights_[idx] == w ) { + return; + } + + bool weight_increases = ( weights_[idx] < w ); weights_[idx] = w; typedef std::tuple KDTreeNode; @@ -223,10 +227,21 @@ increase_weight(PointHandle p, DistanceType w) min_w = weights_[im]; } - if (subtree_weights_[im] < min_w ) // increase weight - subtree_weights_[im] = min_w; - else - break; + if (weight_increases) { + + if (subtree_weights_[im] < min_w ) // increase weight + subtree_weights_[im] = min_w; + else + break; + + } else { + + if (subtree_weights_[im] > min_w ) // decrease weight + subtree_weights_[im] = min_w; + else + break; + + } } } -- cgit v1.2.3