From 1b73f15ff94929e8a4c3b60aecfbe01a9ba1ed4b Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Tue, 1 Sep 2020 22:09:29 -0700 Subject: [PATCH] fix == operator --- .../NondeterministicBeliefTracker.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/storm-pomdp/generator/NondeterministicBeliefTracker.cpp b/src/storm-pomdp/generator/NondeterministicBeliefTracker.cpp index c0d3bd3e8..09bece2c7 100644 --- a/src/storm-pomdp/generator/NondeterministicBeliefTracker.cpp +++ b/src/storm-pomdp/generator/NondeterministicBeliefTracker.cpp @@ -1,5 +1,6 @@ #include "storm-pomdp/generator/NondeterministicBeliefTracker.h" +#include "storm/utility/ConstantsComparator.h" namespace storm { namespace generator { @@ -87,7 +88,24 @@ namespace storm { template bool operator==(SparseBeliefState const& lhs, SparseBeliefState const& rhs) { - return lhs.hash() == rhs.hash() && lhs.belief == rhs.belief; + if (lhs.hash() != rhs.hash()) { + return false; + } + if (lhs.belief.size() != rhs.belief.size()) { + return false; + } + storm::utility::ConstantsComparator cmp(0.00001, true); + auto lhsIt = lhs.belief.begin(); + auto rhsIt = rhs.belief.begin(); + while(lhsIt != lhs.belief.end()) { + if (lhsIt->first != rhsIt->first || !cmp.isEqual(lhsIt->second, rhsIt->second)) { + return false; + } + ++lhsIt; + ++rhsIt; + } + return true; + //return std::equal(lhs.belief.begin(), lhs.belief.end(), rhs.belief.begin()); } template @@ -115,7 +133,7 @@ namespace storm { for(auto& entry : newBelief) { assert(!storm::utility::isZero(sum)); entry.second /= sum; - boost::hash_combine(newHash, std::hash()(entry.second)); + //boost::hash_combine(newHash, std::hash()(entry.second)); boost::hash_combine(newHash, entry.first); risk += entry.second * manager->getRisk(entry.first); }