More whitespace cleanups

This commit is contained in:
Tiago Gomes
2012-12-20 23:19:10 +00:00
parent 421d6f72ee
commit 01d8f8e178
61 changed files with 209 additions and 210 deletions

View File

@@ -4,7 +4,6 @@
#include <vector>
#include <queue>
#include <list>
#include <map>
#include "FactorGraph.h"
#include "BayesBallGraph.h"
@@ -15,8 +14,8 @@ using namespace std;
struct ScheduleInfo
{
ScheduleInfo (BBNode* n, bool vfp, bool vfc) :
node(n), visitedFromParent(vfp), visitedFromChild(vfc) { }
ScheduleInfo (BBNode* n, bool vfp, bool vfc)
: node(n), visitedFromParent(vfp), visitedFromChild(vfc) { }
BBNode* node;
bool visitedFromParent;
@@ -30,7 +29,7 @@ typedef queue<ScheduleInfo, list<ScheduleInfo>> Scheduling;
class BayesBall
{
public:
BayesBall (FactorGraph& fg)
BayesBall (FactorGraph& fg)
: fg_(fg) , dag_(fg.getStructure())
{
dag_.clear();
@@ -63,7 +62,7 @@ inline void
BayesBall::scheduleParents (const BBNode* n, Scheduling& sch) const
{
const vector<BBNode*>& ps = n->parents();
for (vector<BBNode*>::const_iterator it = ps.begin();
for (vector<BBNode*>::const_iterator it = ps.begin();
it != ps.end(); ++it) {
sch.push (ScheduleInfo (*it, false, true));
}

View File

@@ -30,15 +30,15 @@ class BBNode : public Var
void addChild (BBNode* c) { childs_.push_back (c); }
bool isVisited (void) const { return visited_; }
void setAsVisited (void) { visited_ = true; }
bool isMarkedOnTop (void) const { return markedOnTop_; }
void markOnTop (void) { markedOnTop_ = true; }
bool isMarkedOnBottom (void) const { return markedOnBottom_; }
void markOnBottom (void) { markedOnBottom_ = true; }
void clear (void) { visited_ = markedOnTop_ = markedOnBottom_ = false; }

View File

@@ -146,7 +146,7 @@ BeliefProp::getFactorJoint (
if (Globals::logDomain) {
Util::exp (jointDist);
}
return jointDist;
return jointDist;
}
@@ -185,7 +185,7 @@ BeliefProp::runSolver (void)
}
if (Globals::verbosity > 0) {
if (nIters_ < BpOptions::maxIter) {
cout << "Belief propagation converged in " ;
cout << "Belief propagation converged in " ;
cout << nIters_ << " iterations" << endl;
} else {
cout << "The maximum number of iterations was hit, terminating..." ;
@@ -459,7 +459,7 @@ void
BeliefProp::printLinkInformation (void) const
{
for (size_t i = 0; i < links_.size(); i++) {
BpLink* l = links_[i];
BpLink* l = links_[i];
cout << l->toString() << ":" << endl;
cout << " curr msg = " ;
cout << l->message() << endl;

View File

@@ -17,7 +17,7 @@ class BpLink
{
public:
BpLink (FacNode* fn, VarNode* vn)
{
{
fac_ = fn;
var_ = vn;
v1_.resize (vn->range(), LogAware::log (1.0 / vn->range()));
@@ -46,7 +46,7 @@ class BpLink
residual_ = LogAware::getMaxNorm (v1_,v2_);
}
virtual void updateMessage (void)
virtual void updateMessage (void)
{
swap (currMsg_, nextMsg_);
}

View File

@@ -190,7 +190,7 @@ ConstraintTree::ConstraintTree (
ConstraintTree::ConstraintTree (vector<vector<string>> names)
{
assert (names.empty() == false);
assert (names.front().empty() == false);
assert (names.front().empty() == false);
unsigned nrLvs = names[0].size();
for (size_t i = 0; i < nrLvs; i++) {
logVars_.push_back (LogVar (i));
@@ -201,7 +201,7 @@ ConstraintTree::ConstraintTree (vector<vector<string>> names)
Tuple t;
for (size_t j = 0; j < names[i].size(); j++) {
assert (names[i].size() == nrLvs);
t.push_back (LiftedUtils::getSymbol (names[i][j]));
t.push_back (LiftedUtils::getSymbol (names[i][j]));
}
addTuple (t);
}
@@ -266,7 +266,7 @@ ConstraintTree::moveToTop (const LogVars& lvs)
assert (pos != logVars_.size());
for (size_t j = pos; j-- > i; ) {
swapLogVar (logVars_[j]);
}
}
}
}
@@ -318,7 +318,7 @@ ConstraintTree::join (ConstraintTree* ct, bool oneTwoOne)
} else {
moveToTop (intersect.elements());
ct->moveToTop (intersect.elements());
Tuples tuples;
CTNodes appendNodes;
getTuples (ct->root(), Tuples(), intersect.size(),
@@ -455,7 +455,7 @@ ConstraintTree::singletons (void)
if (isSingleton (logVars_[i])) {
singletons.insert (logVars_[i]);
}
}
}
return singletons;
}
@@ -585,13 +585,13 @@ ConstraintTree::isCountNormalized (const LogVarSet& Ys)
if (countTuples (*it) != count) {
return false;
}
}
}
return true;
}
unsigned
unsigned
ConstraintTree::getConditionalCount (const LogVarSet& Ys)
{
assert (isCountNormalized (Ys));
@@ -792,7 +792,7 @@ ConstraintTree::jointCountNormalize (
}
for (size_t i = 0; i < normCts1.size(); i++) {
unsigned j;
unsigned j;
for (j = 0; counts1[i] + counts2[j] != N; j++) ;
// cout << "joint-count(" << counts1[i] ;
// cout << "," << counts2[j] << ")" << endl;
@@ -947,7 +947,7 @@ ConstraintTree::getNodesBelow (CTNode* fromHere) const
CTNodes
ConstraintTree::getNodesAtLevel (unsigned level) const
ConstraintTree::getNodesAtLevel (unsigned level) const
{
assert (level <= logVars_.size());
if (level == 0) {
@@ -1057,7 +1057,7 @@ ConstraintTree::join (
} else {
tupleFounded = join (*it, tuple, currIdx + 1, appendNode);
}
}
}
return tupleFounded;
}
@@ -1065,7 +1065,7 @@ ConstraintTree::join (
void
ConstraintTree::getTuples (
CTNode* n,
CTNode* n,
Tuples currTuples,
unsigned stopLevel,
Tuples& tuplesCollected,
@@ -1147,7 +1147,7 @@ ConstraintTree::split (
CTNode* n2,
CTChilds& commChilds,
CTChilds& exclChilds,
unsigned stopLevel)
unsigned stopLevel)
{
CTChilds& childs1 = n1->childs();
for (CTChilds::const_iterator chIt1 = childs1.begin();

View File

@@ -47,8 +47,7 @@ CountingBp::printSolverFlags (void) const
ss << ",max_iter=" << BpOptions::maxIter;
ss << ",accuracy=" << BpOptions::accuracy;
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << ",chkif=" <<
Util::toString (CountingBp::checkForIdenticalFactors);
ss << ",chkif=" << Util::toString (CountingBp::checkForIdenticalFactors);
ss << "]" ;
cout << ss.str() << endl;
}
@@ -139,7 +138,7 @@ CountingBp::setInitialColors (void)
VarColorMap::iterator it = colorMap.find (range);
if (it == colorMap.end()) {
it = colorMap.insert (make_pair (
range, Colors (range + 1, -1))).first;
range, Colors (range + 1, -1))).first;
}
unsigned idx = varNodes[i]->hasEvidence()
? varNodes[i]->getEvidence()

View File

@@ -28,7 +28,7 @@ ElimGraph::ElimGraph (const vector<Factor*>& factors)
}
if (neighbors (n1, n2) == false) {
addEdge (n1, n2);
}
}
}
}
if (vids.size() == 1) {
@@ -86,7 +86,7 @@ ElimGraph::print (void) const
cout << " " << neighs[j]->label();
}
cout << endl;
}
}
}
@@ -142,7 +142,7 @@ ElimGraph::getEliminationOrder (
Factors::const_iterator first = factors.begin();
Factors::const_iterator end = factors.end();
for (; first != end; ++first) {
Util::addToVector (allVids, (*first)->arguments());
Util::addToVector (allVids, (*first)->arguments());
}
TinySet<VarId> elimOrder (allVids);
elimOrder -= TinySet<VarId> (excludedVids);

View File

@@ -143,7 +143,7 @@ class TFactor
assert (idx != args_.size());
assert (obsIdx < ranges_[idx]);
Params newps;
newps.reserve (params_.size() / ranges_[idx]);
newps.reserve (params_.size() / ranges_[idx]);
Indexer indexer (ranges_);
for (unsigned i = 0; i < obsIdx; ++i) {
indexer.incrementDimension (idx);
@@ -285,7 +285,7 @@ class Factor : public TFactor<VarId>
void sumOutLastVariable (void);
void sumOutArgs (const vector<bool>& mask);
void clone (const Factor& f);
};

View File

@@ -171,7 +171,7 @@ FactorGraph::readFromLibDaiFormat (const char* fileName)
std::reverse (vids.begin(), vids.end());
Factor f (vids, ranges, params);
std::reverse (vids.begin(), vids.end());
f.reorderArguments (vids);
f.reorderArguments (vids);
addFactor (f);
}
is.close();
@@ -188,7 +188,7 @@ FactorGraph::addFactor (const Factor& factor)
for (size_t i = 0; i < vids.size(); i++) {
VarMap::const_iterator it = varMap_.find (vids[i]);
if (it != varMap_.end()) {
addEdge (it->second, fn);
addEdge (it->second, fn);
} else {
VarNode* vn = new VarNode (vids[i], fn->factor().range (i));
addVarNode (vn);
@@ -293,7 +293,7 @@ FactorGraph::exportToGraphViz (const char* fileName) const
}
for (size_t i = 0; i < facNodes_.size(); i++) {
out << '"' << facNodes_[i]->getLabel() << '"' ;
out << " [label=\"" << facNodes_[i]->getLabel();
out << " [label=\"" << facNodes_[i]->getLabel();
out << "\"" << ", shape=box]" << endl;
}
for (size_t i = 0; i < facNodes_.size(); i++) {

View File

@@ -76,7 +76,7 @@ class FactorGraph
const FacNodes& facNodes (void) const { return facNodes_; }
void setFactorsAsBayesian (void) { bayesFactors_ = true; }
bool bayesianFactors (void) const { return bayesFactors_; }
size_t nrVarNodes (void) const { return varNodes_.size(); }

View File

@@ -59,10 +59,10 @@ HistogramSet::reset (void)
vector<Histogram>
vector<Histogram>
HistogramSet::getHistograms (unsigned N, unsigned R)
{
HistogramSet hs (N, R);
HistogramSet hs (N, R);
unsigned H = hs.nrHistograms();
vector<Histogram> histograms;
histograms.reserve (H);
@@ -135,7 +135,7 @@ HistogramSet::maxCount (size_t idx) const
}
return size_ - sum;
}
void

View File

@@ -77,7 +77,7 @@ readFactorGraph (FactorGraph& fg, const char* s)
} else if (extension == "fg") {
fg.readFromLibDaiFormat (fileName.c_str());
} else {
cerr << "Error: the probabilistic graphical model must be " ;
cerr << "Error: the probabilistic graphical model must be " ;
cerr << "defined either in a UAI or libDAI file." << endl;
exit (EXIT_FAILURE);
}

View File

@@ -57,7 +57,7 @@ createLiftedNetwork (void)
}
ParfactorList* pfList = new ParfactorList (parfactors);
if (Globals::verbosity > 2) {
Util::printHeader ("SHATTERED PARFACTORS");
pfList->print();
@@ -91,7 +91,7 @@ createGroundNetwork (void)
// read the ranges
Ranges ranges = readUnsignedList (YAP_ArgOfTerm (2, factor));
// read the parameters
Params params = readParameters (YAP_ArgOfTerm (3, factor));
Params params = readParameters (YAP_ArgOfTerm (3, factor));
// read dist id
unsigned distId = (unsigned) YAP_IntOfTerm (YAP_ArgOfTerm (4, factor));
fg->addFactor (Factor (varIds, ranges, params, distId));
@@ -126,7 +126,7 @@ runLiftedSolver (void)
LiftedNetwork* network = (LiftedNetwork*) YAP_IntOfTerm (YAP_ARG1);
ParfactorList pfListCopy (*network->first);
LiftedOperations::absorveEvidence (pfListCopy, *network->second);
LiftedSolver* solver = 0;
switch (Globals::liftedSolver) {
case LiftedSolverType::LVE: solver = new LiftedVe (pfListCopy); break;
@@ -181,7 +181,7 @@ int
runGroundSolver (void)
{
FactorGraph* fg = (FactorGraph*) YAP_IntOfTerm (YAP_ARG1);
vector<VarIds> tasks;
YAP_Term taskList = YAP_ARG2;
while (taskList != YAP_TermNil()) {
@@ -407,7 +407,7 @@ readParfactor (YAP_Term pfTerm)
}
// read the parameters
const Params& params = readParameters (YAP_ArgOfTerm (4, pfTerm));
const Params& params = readParameters (YAP_ArgOfTerm (4, pfTerm));
// read the constraint
Tuples tuples;
@@ -478,7 +478,7 @@ readLiftedEvidence (
obsFormulas.push_back (ObservedFormula (functor, evidence, args));
}
observedList = YAP_TailOfTerm (observedList);
}
}
}

View File

@@ -167,7 +167,7 @@ class MapIndexer
}
}
}
template <typename T>
MapIndexer (
const vector<T>& allArgs,

View File

@@ -128,7 +128,7 @@ double
LeafNode::weight (void) const
{
assert (clause_->isUnit());
if (clause_->posCountedLogVars().empty() == false
if (clause_->posCountedLogVars().empty() == false
|| clause_->negCountedLogVars().empty() == false) {
if (SetOrNode::isSet() == false) {
// return a NaN if we have a SetOrNode

View File

@@ -60,7 +60,7 @@ LiftedOperations::runWeakBayesBall (
const Grounds& query)
{
queue<PrvGroup> todo; // groups to process
set<PrvGroup> done; // processed or in queue
set<PrvGroup> done; // processed or in queue
for (size_t i = 0; i < query.size(); i++) {
ParfactorList::iterator it = pfList.begin();
while (it != pfList.end()) {
@@ -225,7 +225,7 @@ LiftedOperations::absorve (
absorvedPfs.push_back (0);
}
break;
}
}
g->constr()->moveToTop (formulas[i].logVars());
std::pair<ConstraintTree*, ConstraintTree*> res;

View File

@@ -10,7 +10,7 @@ class LiftedOperations
ParfactorList& pfList, const Grounds& query);
static void runWeakBayesBall (
ParfactorList& pfList, const Grounds&);
ParfactorList& pfList, const Grounds&);
static void absorveEvidence (
ParfactorList& pfList, ObservedFormulas& obsFormulas);

View File

@@ -61,7 +61,7 @@ ostream& operator<< (ostream &os, const Symbol& s)
ostream& operator<< (ostream &os, const LogVar& X)
{
const string labels[] = {
"A", "B", "C", "D", "E", "F",
"A", "B", "C", "D", "E", "F",
"G", "H", "I", "J", "K", "M" };
(X >= 12) ? os << "X_" << X.id_ : os << labels[X];
return os;

View File

@@ -51,7 +51,7 @@ class LogVar
}
bool valid (void) const
{
{
return id_ != Util::maxUnsigned();
}
@@ -145,7 +145,7 @@ class Substitution
return X;
}
bool containsReplacementFor (LogVar X) const
bool containsReplacementFor (LogVar X) const
{
return Util::contains (subs_, X);
}

View File

@@ -133,7 +133,7 @@ ProductOperator::toString (void)
stringstream ss;
ss << "just multiplicate " ;
ss << (*g1_)->getAllGroups();
ss << " x " ;
ss << " x " ;
ss << (*g2_)->getAllGroups();
ss << " [cost=" << std::exp (getLogCost()) << "]" << endl;
return ss.str();
@@ -155,7 +155,7 @@ ProductOperator::validOp (Parfactor* g1, Parfactor* g2)
}
size_t idx1 = g1->indexOfGroup (intersect[i]);
size_t idx2 = g2->indexOfGroup (intersect[i]);
if (g1->range (idx1) != g2->range (idx2)) {
if (g1->range (idx1) != g2->range (idx2)) {
return false;
}
}
@@ -713,7 +713,7 @@ LiftedVe::getBestOperation (const Grounds& query)
if ((bestOp == 0) || (cost < bestCost)) {
bestOp = validOps[i];
bestCost = cost;
}
}
}
if (bestCost > largestCost_) {
largestCost_ = bestCost;

View File

@@ -9,7 +9,7 @@ class LiftedOperator
{
public:
virtual ~LiftedOperator (void) { }
virtual double getLogCost (void) = 0;
virtual void apply (void) = 0;
@@ -55,7 +55,7 @@ class ProductOperator : public LiftedOperator
class SumOutOperator : public LiftedOperator
{
public:
SumOutOperator (PrvGroup group, ParfactorList& pfList)
SumOutOperator (PrvGroup group, ParfactorList& pfList)
: group_(group), pfList_(pfList) { }
double getLogCost (void);

View File

@@ -195,7 +195,7 @@ Clause::isPositiveCountedLogVar (LogVar X) const
assert (constr_.logVarSet().contains (X));
return posCountedLvs_.contains (X);
}
bool
@@ -235,7 +235,7 @@ Clause::ipgCandidates (void) const
LogVarSet allLvs = constr_.logVarSet();
allLvs -= ipgLvs_;
allLvs -= posCountedLvs_;
allLvs -= negCountedLvs_;
allLvs -= negCountedLvs_;
for (size_t i = 0; i < allLvs.size(); i++) {
bool valid = true;
for (size_t j = 0; j < literals_.size(); j++) {
@@ -262,7 +262,7 @@ Clause::logVarTypes (size_t litIdx) const
if (posCountedLvs_.contains (lvs[i])) {
types.push_back (LogVarType::POS_LV);
} else if (negCountedLvs_.contains (lvs[i])) {
types.push_back (LogVarType::NEG_LV);
types.push_back (LogVarType::NEG_LV);
} else {
types.push_back (LogVarType::FULL_LV);
}
@@ -391,7 +391,7 @@ LiftedWCNF::LiftedWCNF (const ParfactorList& pfList)
{
addIndicatorClauses (pfList);
addParameterClauses (pfList);
/*
// INCLUSION-EXCLUSION TEST
clauses_.clear();
@@ -579,7 +579,7 @@ LiftedWCNF::addParameterClauses (const ParfactorList& pfList)
// ¬θxi|u1,...,un v λu2 -> tempClause
double posWeight = (**it)[indexer];
addWeight (paramVarLid, posWeight, LogAware::one());
Clause* clause1 = new Clause (*(*it)->constr());
for (unsigned i = 0; i < groups.size(); i++) {
@@ -593,7 +593,7 @@ LiftedWCNF::addParameterClauses (const ParfactorList& pfList)
tempClause->addLiteralComplemented (Literal (
paramVarLid, (*it)->constr()->logVars()));
tempClause->addLiteral (Literal (lid, (*it)->argument(i).logVars()));
clauses_.push_back (tempClause);
clauses_.push_back (tempClause);
}
clause1->addLiteral (Literal (paramVarLid, (*it)->constr()->logVars()));
clauses_.push_back (clause1);

View File

@@ -8,7 +8,7 @@
Parfactor::Parfactor (
const ProbFormulas& formulas,
const Params& params,
const Params& params,
const Tuples& tuples,
unsigned distId)
{
@@ -221,7 +221,7 @@ Parfactor::countConvert (LogVar X)
assert (constr_->isCountNormalized (X));
assert (constr_->getConditionalCount (X) > 1);
assert (canCountConvert (X));
unsigned N = constr_->getConditionalCount (X);
unsigned R = ranges_[fIdx];
unsigned H = HistogramSet::nrHistograms (N, R);
@@ -336,7 +336,7 @@ Parfactor::fullExpand (LogVar X)
sumIndexes.push_back (HistogramSet::findIndex (hist, originHists));
++ indexer;
}
expandPotential (fIdx, std::pow (R, N), sumIndexes);
ProbFormula f = args_[fIdx];
@@ -360,7 +360,7 @@ Parfactor::reorderAccordingGrounds (const Grounds& grounds)
ProbFormulas newFormulas;
for (size_t i = 0; i < grounds.size(); i++) {
for (size_t j = 0; j < args_.size(); j++) {
if (grounds[i].functor() == args_[j].functor() &&
if (grounds[i].functor() == args_[j].functor() &&
grounds[i].arity() == args_[j].arity()) {
constr_->moveToTop (args_[j].logVars());
if (constr_->containsTuple (grounds[i].args())) {
@@ -424,7 +424,7 @@ Parfactor::indexOfGround (const Ground& ground) const
{
size_t idx = args_.size();
for (size_t i = 0; i < args_.size(); i++) {
if (args_[i].functor() == ground.functor() &&
if (args_[i].functor() == ground.functor() &&
args_[i].arity() == ground.arity()) {
constr_->moveToTop (args_[i].logVars());
if (constr_->containsTuple (ground.args())) {
@@ -806,7 +806,7 @@ Parfactor::simplifyParfactor (size_t fIdx1, size_t fIdx2)
while (indexer.valid()) {
if (indexer[fIdx1] == indexer[fIdx2]) {
params_.push_back (backup[indexer]);
}
}
++ indexer;
}
for (size_t i = 0; i < args_[fIdx2].logVars().size(); i++) {
@@ -829,7 +829,7 @@ Parfactor::getAlignLogVars (Parfactor* g1, Parfactor* g2)
TinySet<size_t> matchedI;
TinySet<size_t> matchedJ;
ProbFormulas& formulas1 = g1->arguments();
ProbFormulas& formulas2 = g2->arguments();
ProbFormulas& formulas2 = g2->arguments();
for (size_t i = 0; i < formulas1.size(); i++) {
for (size_t j = 0; j < formulas2.size(); j++) {
if (formulas1[i].group() == formulas2[j].group() &&
@@ -882,7 +882,7 @@ Parfactor::alignLogicalVars (Parfactor* g1, Parfactor* g2)
LogVar freeLogVar (0);
Substitution theta1, theta2;
for (size_t i = 0; i < alignLvs1.size(); i++) {
bool b1 = theta1.containsReplacementFor (alignLvs1[i]);
bool b1 = theta1.containsReplacementFor (alignLvs1[i]);
bool b2 = theta2.containsReplacementFor (alignLvs2[i]);
if (b1 == false && b2 == false) {
theta1.add (alignLvs1[i], freeLogVar);
@@ -911,11 +911,11 @@ Parfactor::alignLogicalVars (Parfactor* g1, Parfactor* g2)
}
// handle this type of situation:
// g1 = p(X), q(X) ; X in {(p1),(p2)}
// g1 = p(X), q(X) ; X in {(p1),(p2)}
// g2 = p(X), q(Y) ; (X,Y) in {(p1,p2),(p2,p1)}
LogVars discardedLvs1 = theta1.getDiscardedLogVars();
for (size_t i = 0; i < discardedLvs1.size(); i++) {
if (g1->constr()->isSingleton (discardedLvs1[i]) &&
if (g1->constr()->isSingleton (discardedLvs1[i]) &&
g1->nrFormulas (discardedLvs1[i]) == 1) {
g1->constr()->remove (discardedLvs1[i]);
} else {

View File

@@ -115,7 +115,7 @@ class Parfactor : public TFactor<ProbFormula>
static void alignLogicalVars (Parfactor*, Parfactor*);
ConstraintTree* constr_;
};

View File

@@ -9,7 +9,7 @@ ParfactorList::ParfactorList (const ParfactorList& pfList)
while (it != pfList.end()) {
addShattered (new Parfactor (**it));
++ it;
}
}
}
@@ -74,7 +74,7 @@ ParfactorList::insertShattered (
list<Parfactor*>::iterator
ParfactorList::remove (list<Parfactor*>::iterator it)
ParfactorList::remove (list<Parfactor*>::iterator it)
{
return pfList_.erase (it);
}
@@ -418,7 +418,7 @@ ParfactorList::shatter (Parfactor* g1, Parfactor* g2)
if (formulas1[i].sameSkeletonAs (formulas2[j])) {
std::pair<Parfactors, Parfactors> res;
res = shatter (i, g1, j, g2);
if (res.first.empty() == false ||
if (res.first.empty() == false ||
res.second.empty() == false) {
return res;
}
@@ -470,7 +470,7 @@ ParfactorList::shatter (
ConstraintTree* exclCt1 = split1.second;
if (commCt1->empty()) {
// disjoint
// disjoint
delete commCt1;
delete exclCt1;
return { };
@@ -549,11 +549,11 @@ ParfactorList::shatter (
Parfactor* newPf = new Parfactor (g, cts[i]);
if (cts[i]->nrLogVars() == g->constr()->nrLogVars() + 1) {
newPf->expand (f.countedLogVar(), X_new1, X_new2);
assert (g->constr()->getConditionalCount (f.countedLogVar()) ==
assert (g->constr()->getConditionalCount (f.countedLogVar()) ==
cts[i]->getConditionalCount (X_new1) +
cts[i]->getConditionalCount (X_new2));
} else {
assert (g->constr()->getConditionalCount (f.countedLogVar()) ==
assert (g->constr()->getConditionalCount (f.countedLogVar()) ==
cts[i]->getConditionalCount (f.countedLogVar()));
}
newPf->setNewGroups();

View File

@@ -61,7 +61,7 @@ ProbFormula::countedLogVar (void) const
}
void
ProbFormula::setCountedLogVar (LogVar lv)
{
@@ -92,9 +92,10 @@ ProbFormula::rename (LogVar oldName, LogVar newName)
}
bool operator== (const ProbFormula& f1, const ProbFormula& f2)
{
return f1.group_ == f2.group_ &&
{
return f1.group_ == f2.group_ &&
f1.logVars_ == f2.logVars_;
}

View File

@@ -12,11 +12,11 @@ typedef unsigned long PrvGroup;
class ProbFormula
{
public:
ProbFormula (Symbol f, const LogVars& lvs, unsigned range)
ProbFormula (Symbol f, const LogVars& lvs, unsigned range)
: functor_(f), logVars_(lvs), range_(range),
countedLogVar_(), group_(numeric_limits<PrvGroup>::max()) { }
ProbFormula (Symbol f, unsigned r)
ProbFormula (Symbol f, unsigned r)
: functor_(f), range_(r), group_(numeric_limits<PrvGroup>::max()) { }
Symbol functor (void) const { return functor_; }
@@ -76,10 +76,10 @@ typedef vector<ProbFormula> ProbFormulas;
class ObservedFormula
{
public:
ObservedFormula (Symbol f, unsigned a, unsigned ev)
ObservedFormula (Symbol f, unsigned a, unsigned ev)
: functor_(f), arity_(a), evidence_(ev), constr_(a) { }
ObservedFormula (Symbol f, unsigned ev, const Tuple& tuple)
ObservedFormula (Symbol f, unsigned ev, const Tuple& tuple)
: functor_(f), arity_(tuple.size()), evidence_(ev), constr_(arity_)
{
constr_.addTuple (tuple);

View File

@@ -21,7 +21,7 @@ class TinySet
TinySet (const Compare& cmp = Compare())
: vec_(), cmp_(cmp) { }
TinySet (const T& t, const Compare& cmp = Compare())
TinySet (const T& t, const Compare& cmp = Compare())
: vec_(1, t), cmp_(cmp) { }
TinySet (const vector<T>& elements, const Compare& cmp = Compare())
@@ -153,12 +153,12 @@ class TinySet
{
return vec_[i];
}
T& operator[] (typename vector<T>::size_type i)
{
return vec_[i];
}
T front (void) const
{
return vec_.front();
@@ -219,7 +219,7 @@ class TinySet
return ! (s1.vec_ == s2.vec_);
}
friend std::ostream& operator << (std::ostream& out, const TinySet& s)
friend std::ostream& operator<< (std::ostream& out, const TinySet& s)
{
out << "{" ;
typename vector<T>::size_type i;

View File

@@ -140,7 +140,7 @@ nrDigits (int num)
{
unsigned count = 1;
while (num >= 10) {
num /= 10;
num /= 10;
count ++;
}
return count;
@@ -166,7 +166,7 @@ parametersToString (const Params& v, unsigned precision)
{
stringstream ss;
ss.precision (precision);
ss << "[" ;
ss << "[" ;
for (size_t i = 0; i < v.size(); i++) {
if (i != 0) ss << ", " ;
ss << v[i];

View File

@@ -373,8 +373,8 @@ void operator^=(std::vector<T>& v, int iexp)
template <typename T>
std::ostream& operator << (std::ostream& os, const vector<T>& v)
template <typename T>
std::ostream& operator<< (std::ostream& os, const vector<T>& v)
{
os << "[" ;
os << Util::elementsToString (v, ", ");

View File

@@ -49,7 +49,7 @@ Var::isValidState (const string& stateName)
void
Var::setEvidence (int ev)
Var::setEvidence (int ev)
{
assert (ev < (int) range_);
evidence_ = ev;
@@ -58,8 +58,8 @@ Var::setEvidence (int ev)
void
Var::setEvidence (const string& ev)
{
Var::setEvidence (const string& ev)
{
States states = Var::getVarInfo (varId_).states;
for (size_t i = 0; i < states.size(); i++) {
if (states[i] == ev) {

View File

@@ -70,7 +70,7 @@ VarElim::createFactorList (void)
factorList_.push_back (new Factor (facNodes[i]->factor()));
const VarNodes& neighs = facNodes[i]->neighbors();
for (size_t j = 0; j < neighs.size(); j++) {
unordered_map<VarId, vector<size_t>>::iterator it
unordered_map<VarId, vector<size_t>>::iterator it
= varFactors_.find (neighs[j]->varId());
if (it == varFactors_.end()) {
it = varFactors_.insert (make_pair (

View File

@@ -132,7 +132,7 @@ WeightedBp::maxResidualSchedule (void)
}
}
// in counting bp, the message that a variable X sends to
// to a factor F depends on the message that F sent to the X
// to a factor F depends on the message that F sent to the X
const BpLinks& links = ninf(link->facNode())->getLinks();
for (size_t i = 0; i < links.size(); i++) {
if (links[i]->varNode() != link->varNode()) {
@@ -258,7 +258,7 @@ WeightedBp::getVarToFactorMsg (const BpLink* _link) const
if ( ! (l->facNode() == dst && l->index() == link->index())) {
msg *= l->powMessage();
if (Constants::SHOW_BP_CALCS) {
cout << " x " << l->nextMessage() << "^" << link->weight();
cout << " x " << l->nextMessage() << "^" << link->weight();
}
}
}

View File

@@ -6,7 +6,7 @@
class WeightedLink : public BpLink
{
public:
WeightedLink (FacNode* fn, VarNode* vn, size_t idx, unsigned weight)
WeightedLink (FacNode* fn, VarNode* vn, size_t idx, unsigned weight)
: BpLink (fn, vn), index_(idx), weight_(weight),
pwdMsg_(vn->range(), LogAware::one()) { }
@@ -16,7 +16,7 @@ class WeightedLink : public BpLink
const Params& powMessage (void) const { return pwdMsg_; }
void updateMessage (void)
void updateMessage (void)
{
pwdMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);