From 3887e8a979b651569234cc3748e458abd45c4cd4 Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Sat, 28 Mar 2020 20:28:15 +0100 Subject: [PATCH] Fix for belief triangulation. More descriptive output for belief triangulation asserts. --- src/storm-pomdp/storage/BeliefGrid.h | 32 ++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/storm-pomdp/storage/BeliefGrid.h b/src/storm-pomdp/storage/BeliefGrid.h index 48da1b85b..b0661fcc5 100644 --- a/src/storm-pomdp/storage/BeliefGrid.h +++ b/src/storm-pomdp/storage/BeliefGrid.h @@ -42,6 +42,32 @@ namespace storm { return idIt->second; } + std::string toString(BeliefType const& belief) const { + std::stringstream str; + str << "{ "; + bool first = true; + for (auto const& entry : belief) { + if (first) { + first = false; + } else { + str << ", "; + } + str << entry.first << ": " << entry.second; + } + str << " }"; + return str.str(); + } + + std::string toString(Triangulation const& t) const { + std::stringstream str; + str << "(\n"; + for (uint64_t i = 0; i < t.size(); ++i) { + str << "\t" << t.weights[i] << " * \t" << toString(getGridPoint(t.gridPoints[i])) << "\n"; + } + str <<")\n"; + return str.str(); + } + bool isEqual(BeliefType const& first, BeliefType const& second) const { if (first.size() != second.size()) { return false; @@ -132,7 +158,7 @@ namespace storm { STORM_LOG_ERROR("Triangulated belief is not a belief."); } if (!isEqual(belief, triangulatedBelief)) { - STORM_LOG_ERROR("Belief does not match triangulated belief."); + STORM_LOG_ERROR("Belief:\n\t" << toString(belief) << "\ndoes not match triangulated belief:\n\t" << toString(triangulatedBelief) << "."); return false; } return true; @@ -233,10 +259,8 @@ namespace storm { result.gridPoints.push_back(getOrAddGridPointId(gridPoint)); } } - std::reverse(result.weights.begin(), result.weights.end()); - - STORM_LOG_ASSERT(assertTriangulation(belief, result), "Incorrect triangulation."); + STORM_LOG_ASSERT(assertTriangulation(belief, result), "Incorrect triangulation: " << toString(result)); return result; }