don't use a stack for atom counting operator
This commit is contained in:
parent
57a31c2c36
commit
907144db32
@ -23,7 +23,8 @@ AndNode::weight (void) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
stack<pair<unsigned, unsigned>> SetOrNode::nrGrsStack;
|
int SetOrNode::nrPos_ = -1;
|
||||||
|
int SetOrNode::nrNeg_ = -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,8 @@ SetOrNode::weight (void) const
|
|||||||
{
|
{
|
||||||
double weightSum = LogAware::addIdenty();
|
double weightSum = LogAware::addIdenty();
|
||||||
for (unsigned i = 0; i < nrGroundings_ + 1; i++) {
|
for (unsigned i = 0; i < nrGroundings_ + 1; i++) {
|
||||||
nrGrsStack.push (make_pair (nrGroundings_ - i, i));
|
nrPos_ = nrGroundings_ - i;
|
||||||
|
nrNeg_ = i;
|
||||||
if (Globals::logDomain) {
|
if (Globals::logDomain) {
|
||||||
double nrCombs = Util::nrCombinations (nrGroundings_, i);
|
double nrCombs = Util::nrCombinations (nrGroundings_, i);
|
||||||
double w = follow_->weight();
|
double w = follow_->weight();
|
||||||
@ -42,6 +44,8 @@ SetOrNode::weight (void) const
|
|||||||
weightSum += Util::nrCombinations (nrGroundings_, i) * w;
|
weightSum += Util::nrCombinations (nrGroundings_, i) * w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nrPos_ = -1;
|
||||||
|
nrNeg_ = -1;
|
||||||
return weightSum;
|
return weightSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,19 +75,19 @@ class SetOrNode : public CircuitNode
|
|||||||
|
|
||||||
CircuitNode** follow (void) { return &follow_; }
|
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;
|
double weight (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircuitNode* follow_;
|
CircuitNode* follow_;
|
||||||
unsigned nrGroundings_;
|
unsigned nrGroundings_;
|
||||||
|
static int nrPos_;
|
||||||
static stack<pair<unsigned, unsigned>> nrGrsStack;
|
static int nrNeg_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user