summaryrefslogtreecommitdiff
path: root/geom_matching/wasserstein/include
diff options
context:
space:
mode:
Diffstat (limited to 'geom_matching/wasserstein/include')
-rw-r--r--geom_matching/wasserstein/include/auction_oracle.h25
-rw-r--r--geom_matching/wasserstein/include/auction_runner_gs.h8
-rw-r--r--geom_matching/wasserstein/include/auction_runner_jac.h4
-rw-r--r--geom_matching/wasserstein/include/basic_defs_ws.h4
-rw-r--r--geom_matching/wasserstein/include/def_debug_ws.h4
-rw-r--r--geom_matching/wasserstein/include/dnn/local/kd-tree.h2
-rw-r--r--geom_matching/wasserstein/include/dnn/local/kd-tree.hpp29
-rw-r--r--geom_matching/wasserstein/include/wasserstein.h22
8 files changed, 59 insertions, 39 deletions
diff --git a/geom_matching/wasserstein/include/auction_oracle.h b/geom_matching/wasserstein/include/auction_oracle.h
index e803218..ef6ec53 100644
--- a/geom_matching/wasserstein/include/auction_oracle.h
+++ b/geom_matching/wasserstein/include/auction_oracle.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2015, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -12,7 +12,7 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
@@ -54,7 +54,7 @@ struct CompPairsBySecondStruct {
}
};
-//
+//
struct CompPairsBySecondGreaterStruct {
bool operator()(const IdxValPair& a, const IdxValPair& b) const
{
@@ -105,17 +105,22 @@ public:
handle = push(newVal);
}
- size_t size() const
- {
+ void increase(handle_type& handle, const IdxValPair& newVal)
+ {
+ _heap.erase(handle);
+ handle = push(newVal);
+
+ size_t size() const
+ {
return _heap.size();
}
- handle_type ordered_begin()
+ handle_type ordered_begin()
{
return _heap.begin();
}
- handle_type ordered_end()
+ handle_type ordered_end()
{
return _heap.end();
}
@@ -211,9 +216,9 @@ struct AuctionOracleLazyHeapRestricted final : AuctionOracleAbstract {
std::vector<LossesHeap::handle_type> diagHeapHandles;
std::vector<size_t> heapHandlesIndices;
// debug
-
+
DebugOptimalBid getOptimalBidDebug(const IdxType bidderIdx);
-
+
// for diagonal points
bool bestDiagonalItemsComputed;
size_t bestDiagonalItemIdx;
@@ -292,7 +297,7 @@ struct AuctionOracleRestricted final : AuctionOracleAbstract {
void setPrice(const IdxType itemsIdx, const double newPrice) override;
void adjustPrices(void) override {};
void setEpsilon(double newEpsilon) override { assert(newEpsilon >= 0.0); epsilon = newEpsilon; };
- // data
+ // data
std::vector<std::vector<double>> weightMatrix;
double maxVal;
constexpr static bool isRestricted = true;
diff --git a/geom_matching/wasserstein/include/auction_runner_gs.h b/geom_matching/wasserstein/include/auction_runner_gs.h
index 7968fa9..ce139f1 100644
--- a/geom_matching/wasserstein/include/auction_runner_gs.h
+++ b/geom_matching/wasserstein/include/auction_runner_gs.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2016, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -12,7 +12,7 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
@@ -34,7 +34,7 @@ derivative works thereof, in binary and source code form.
#include "auction_oracle.h"
//#define KEEP_UNASSIGNED_ORDERED
-// if this symbol is defined,
+// if this symbol is defined,
// unassigned bidders are processed in a lexicographic order.
// See LexicogrCompDiagramPoint comparator.
@@ -80,7 +80,7 @@ public:
double getWassersteinDistance();
double getWassersteinCost();
double getRelativeError() const { return relativeError; };
- static constexpr int maxIterNum { 25 }; // maximal number of iterations of epsilon-scaling
+ static constexpr int maxIterNum { 35 }; // maximal number of iterations of epsilon-scaling
private:
// private data
std::vector<DiagramPoint> bidders, items;
diff --git a/geom_matching/wasserstein/include/auction_runner_jac.h b/geom_matching/wasserstein/include/auction_runner_jac.h
index 524498a..d8cada6 100644
--- a/geom_matching/wasserstein/include/auction_runner_jac.h
+++ b/geom_matching/wasserstein/include/auction_runner_jac.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2016, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -12,7 +12,7 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
diff --git a/geom_matching/wasserstein/include/basic_defs_ws.h b/geom_matching/wasserstein/include/basic_defs_ws.h
index 474af22..a87ccd3 100644
--- a/geom_matching/wasserstein/include/basic_defs_ws.h
+++ b/geom_matching/wasserstein/include/basic_defs_ws.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2015, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -62,7 +62,7 @@ struct Point {
#endif
};
-struct DiagramPoint
+struct DiagramPoint
{
// data members
// Points above the diagonal have type NORMAL
diff --git a/geom_matching/wasserstein/include/def_debug_ws.h b/geom_matching/wasserstein/include/def_debug_ws.h
index 6751556..d4450b2 100644
--- a/geom_matching/wasserstein/include/def_debug_ws.h
+++ b/geom_matching/wasserstein/include/def_debug_ws.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2015, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -12,7 +12,7 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
(Enhancements) to anyone; however, if you choose to make your Enhancements
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<class T>
void
dnn::KDTree<T>::
-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<HCIterator, HCIterator> 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;
+
+ }
}
}
diff --git a/geom_matching/wasserstein/include/wasserstein.h b/geom_matching/wasserstein/include/wasserstein.h
index 155d79d..c3e9280 100644
--- a/geom_matching/wasserstein/include/wasserstein.h
+++ b/geom_matching/wasserstein/include/wasserstein.h
@@ -1,5 +1,5 @@
/*
-
+
Copyright (c) 2015, M. Kerber, D. Morozov, A. Nigmetov
All rights reserved.
@@ -12,7 +12,7 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
@@ -43,18 +43,18 @@ namespace geom_ws {
using PairVector = std::vector<std::pair<double, double>>;
// get Wasserstein distance between two persistence diagrams
-double wassersteinDistVec(const std::vector<DiagramPoint>& A,
- const std::vector<DiagramPoint>& B,
- const double q,
+double wassersteinDistVec(const std::vector<DiagramPoint>& A,
+ const std::vector<DiagramPoint>& B,
+ const double q,
const double delta,
const double _internal_p = std::numeric_limits<double>::infinity(),
const double _initialEpsilon = 0.0,
const double _epsFactor = 0.0);
// get Wasserstein cost (distance^q) between two persistence diagrams
-double wassersteinCostVec(const std::vector<DiagramPoint>& A,
- const std::vector<DiagramPoint>& B,
- const double q,
+double wassersteinCostVec(const std::vector<DiagramPoint>& A,
+ const std::vector<DiagramPoint>& B,
+ const double q,
const double delta,
const double _internal_p = std::numeric_limits<double>::infinity(),
const double _initialEpsilon = 0.0,
@@ -119,7 +119,7 @@ double wassersteinDist(PairContainer& A, PairContainer& B, const double q, const
if (b_empty)
dgmB.clear();
-
+
return wassersteinDistVec(dgmA, dgmB, q, delta, _internal_p, _initialEpsilon, _epsFactor);
}
@@ -146,7 +146,7 @@ double wassersteinCost(PairContainer& A, PairContainer& B, const double q, const
dgmA.push_back(DiagramPoint(x, y, DiagramPoint::DIAG));
dgmB.push_back(DiagramPoint(x, y, DiagramPoint::NORMAL));
}
-
+
return wassersteinCostVec(dgmA, dgmB, q, delta, _internal_p, _initialEpsilon, _epsFactor);
}
@@ -157,7 +157,7 @@ double wassersteinCost(PairContainer& A, PairContainer& B, const double q, const
bool readDiagramPointSet(const char* fname, PairVector& result);
bool readDiagramPointSet(const std::string& fname, PairVector& result);
void removeDuplicates(PairVector& dgmA, PairVector& dgmB);
-
+
} // end of namespace geom_ws
#endif