summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2022-09-17 14:47:42 +0200
committerJaron Kent-Dobias <jaron@kent-dobias.com>2022-09-17 14:47:42 +0200
commit291d2ea1bf6994f4c58be5c177ec566fa94f1b64 (patch)
tree2c605276529329693bfcf73d3f71ee0ed8596b0d
parent615d389aaabf81ca8e0e86de6c7cff9ecb9b498b (diff)
downloadcode-291d2ea1bf6994f4c58be5c177ec566fa94f1b64.tar.gz
code-291d2ea1bf6994f4c58be5c177ec566fa94f1b64.tar.bz2
code-291d2ea1bf6994f4c58be5c177ec566fa94f1b64.zip
Changes to how the propogation happens.
-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++;
}