From 291d2ea1bf6994f4c58be5c177ec566fa94f1b64 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sat, 17 Sep 2022 14:47:42 +0200 Subject: Changes to how the propogation happens. --- rbmp.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/rbmp.cpp b/rbmp.cpp index 7d43d14..ffc7c44 100644 --- a/rbmp.cpp +++ b/rbmp.cpp @@ -31,10 +31,9 @@ private: public: const Edge& edge; - double oldX; double X; - HalfEdge(const Edge& e) : edge(e), oldX(0) {} + HalfEdge(const Edge& e) : edge(e), X(0) {} void setVertices(Vertex& vt, Vertex& vh) { tail = &vt; head = &vh; @@ -88,25 +87,26 @@ public: } } - double propagateBeliefs() { -# pragma omp parallel for - for (Edge& e : edges) { - for (HalfEdge& h : e.halfedges) { + void propagateBeliefs() { + for (unsigned i : {0, 1}) { +#pragma omp parallel for + for (Edge& e : edges) { + HalfEdge& h = e.halfedges[i]; h.X = std::numeric_limits::infinity(); for (const HalfEdge& hn : h.getHead().neighbors) { if (h.getTail().index != hn.getHead().index) { - h.X = std::min(hn.edge.weight - hn.oldX, h.X); + h.X = std::min(hn.edge.weight - hn.X, h.X); } } } } + } + double minBelief() const { double minBelief = std::numeric_limits::infinity(); - for (Edge& e : edges) { + + for (const Edge& e : edges) { minBelief = std::min(std::abs(e.belief()), minBelief); - for (HalfEdge& he : e.halfedges) { - he.oldX = he.X; - } } return minBelief; @@ -143,7 +143,10 @@ int main(int argc, char* argv[]) { double minBelief = 0; while (minBelief < beliefThreshold && steps < maxSteps) { - minBelief = G.propagateBeliefs(); + G.propagateBeliefs(); + if (steps % 100 == 0) { + std::cerr << (minBelief = G.minBelief()) << std::endl; + } steps++; } -- cgit v1.2.3-70-g09d2