From c563d463ffce73b070b35e62baf980d19d0bc4ac Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Thu, 31 May 2018 23:42:22 +0200 Subject: 2 bugs fixed in Jacobi for point cloud --- .../wasserstein/example/wasserstein_dist_point_cloud.cpp | 2 +- .../wasserstein/include/auction_oracle_kdtree_restricted.hpp | 4 ++-- geom_matching/wasserstein/include/auction_runner_jac.hpp | 9 +++++++-- geom_matching/wasserstein/include/wasserstein_pure_geom.hpp | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/geom_matching/wasserstein/example/wasserstein_dist_point_cloud.cpp b/geom_matching/wasserstein/example/wasserstein_dist_point_cloud.cpp index 6f699a4..2f9718e 100644 --- a/geom_matching/wasserstein/example/wasserstein_dist_point_cloud.cpp +++ b/geom_matching/wasserstein/example/wasserstein_dist_point_cloud.cpp @@ -35,6 +35,7 @@ derivative works thereof, in binary and source code form. int main(int argc, char* argv[]) { + //{ //int n_points = 3; //int dim = 3; @@ -106,7 +107,6 @@ int main(int argc, char* argv[]) params.dim = dimension_A; - params.wasserstein_power = (4 <= argc) ? atof(argv[3]) : 1.0; if (params.wasserstein_power < 1.0) { std::cerr << "The third argument (wasserstein_degree) was \"" << argv[3] << "\", must be a number >= 1.0. Cannot proceed. " << std::endl; diff --git a/geom_matching/wasserstein/include/auction_oracle_kdtree_restricted.hpp b/geom_matching/wasserstein/include/auction_oracle_kdtree_restricted.hpp index 7817bf3..3c3cba3 100644 --- a/geom_matching/wasserstein/include/auction_oracle_kdtree_restricted.hpp +++ b/geom_matching/wasserstein/include/auction_oracle_kdtree_restricted.hpp @@ -243,7 +243,7 @@ AuctionOracleKDTreeRestricted::get_optimal_bid_debug(Idx Real best_item_value = std::numeric_limits::max(); Real second_best_item_value = std::numeric_limits::max(); - for(IdxType item_idx = 0; item_idx < this->items.size(); ++item_idx) { + for(IdxType item_idx = 0; item_idx < static_cast(this->items.size()); ++item_idx) { auto item = this->items[item_idx]; if (item.type != bidder.type and item_idx != bidder_idx) continue; @@ -258,7 +258,7 @@ AuctionOracleKDTreeRestricted::get_optimal_bid_debug(Idx for(size_t item_idx = 0; item_idx < this->items.size(); ++item_idx) { auto item = this->items[item_idx]; - if (item.type != bidder.type and item_idx != bidder_idx) + if (item.type != bidder.type and static_cast(item_idx) != bidder_idx) continue; if (item_idx == best_item_idx) continue; diff --git a/geom_matching/wasserstein/include/auction_runner_jac.hpp b/geom_matching/wasserstein/include/auction_runner_jac.hpp index 8663bae..c519de1 100644 --- a/geom_matching/wasserstein/include/auction_runner_jac.hpp +++ b/geom_matching/wasserstein/include/auction_runner_jac.hpp @@ -42,7 +42,6 @@ derivative works thereof, in binary and source code form. #undef DEBUG_AUCTION #endif - namespace hera { namespace ws { @@ -350,6 +349,8 @@ namespace ws { typename AuctionRunnerJac::Real AuctionRunnerJac::get_relative_error(const bool debug_output) const { + if (partial_cost == 0.0 and unassigned_bidders.empty()) + return 0.0; Real result; #ifndef WASSERSTEIN_PURE_GEOM Real gamma = get_gamma(); @@ -560,7 +561,7 @@ namespace ws { wasserstein_cost = get_item_bidder_cost(0,0); return; } - double init_eps = (initial_epsilon > 0.0) ? initial_epsilon : oracle.max_val_ / 4.0; + R init_eps = (initial_epsilon > 0.0) ? initial_epsilon : oracle.max_val_ / 4.0; run_auction_phases(max_num_phases, init_eps); is_distance_computed = true; wasserstein_cost = partial_cost; @@ -703,7 +704,11 @@ namespace ws { template bool AuctionRunnerJac::continue_auction_phase() const { +#ifdef WASSERSTEIN_PURE_GEOM + return not unassigned_bidders.empty(); +#else return not unassigned_bidders.empty() and not is_done(); +#endif } template diff --git a/geom_matching/wasserstein/include/wasserstein_pure_geom.hpp b/geom_matching/wasserstein/include/wasserstein_pure_geom.hpp index 13a94d5..096d95d 100644 --- a/geom_matching/wasserstein/include/wasserstein_pure_geom.hpp +++ b/geom_matching/wasserstein/include/wasserstein_pure_geom.hpp @@ -72,7 +72,6 @@ inline double wasserstein_cost(const DynamicPointVector& set_A, const Dy auction.run_auction(); return auction.get_wasserstein_cost(); } - } inline double wasserstein_dist(const DynamicPointVector& set_A, const DynamicPointVector& set_B, const AuctionParams& params) -- cgit v1.2.3