summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbmp.cpp27
1 files 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<double>::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<double>::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++;
}