From 907144db321ad3f0cd692b09f141601f64c71c6a Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Sun, 9 Dec 2012 19:46:14 +0000 Subject: [PATCH] don't use a stack for atom counting operator --- packages/CLPBN/horus/LiftedCircuit.cpp | 8 ++++++-- packages/CLPBN/horus/LiftedCircuit.h | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/CLPBN/horus/LiftedCircuit.cpp b/packages/CLPBN/horus/LiftedCircuit.cpp index d330f2a68..4012aa8a8 100644 --- a/packages/CLPBN/horus/LiftedCircuit.cpp +++ b/packages/CLPBN/horus/LiftedCircuit.cpp @@ -23,7 +23,8 @@ AndNode::weight (void) const -stack> SetOrNode::nrGrsStack; +int SetOrNode::nrPos_ = -1; +int SetOrNode::nrNeg_ = -1; @@ -32,7 +33,8 @@ SetOrNode::weight (void) const { double weightSum = LogAware::addIdenty(); for (unsigned i = 0; i < nrGroundings_ + 1; i++) { - nrGrsStack.push (make_pair (nrGroundings_ - i, i)); + nrPos_ = nrGroundings_ - i; + nrNeg_ = i; if (Globals::logDomain) { double nrCombs = Util::nrCombinations (nrGroundings_, i); double w = follow_->weight(); @@ -42,6 +44,8 @@ SetOrNode::weight (void) const weightSum += Util::nrCombinations (nrGroundings_, i) * w; } } + nrPos_ = -1; + nrNeg_ = -1; return weightSum; } diff --git a/packages/CLPBN/horus/LiftedCircuit.h b/packages/CLPBN/horus/LiftedCircuit.h index 070d0f8d9..3acdf7285 100644 --- a/packages/CLPBN/horus/LiftedCircuit.h +++ b/packages/CLPBN/horus/LiftedCircuit.h @@ -75,19 +75,19 @@ class SetOrNode : public CircuitNode CircuitNode** follow (void) { return &follow_; } - static unsigned nrPositives (void) { return nrGrsStack.top().first; } + static unsigned nrPositives (void) { return nrPos_; } - static unsigned nrNegatives (void) { return nrGrsStack.top().second; } + static unsigned nrNegatives (void) { return nrNeg_; } - static bool isSet (void) { return nrGrsStack.size() > 0; } + static bool isSet (void) { return nrPos_ >= 0; } double weight (void) const; private: CircuitNode* follow_; unsigned nrGroundings_; - - static stack> nrGrsStack; + static int nrPos_; + static int nrNeg_; };