Handle better formulas like f(X,X)

This commit is contained in:
Tiago Gomes
2012-12-18 23:51:51 +00:00
parent 0a661b0462
commit 691188d5c9
3 changed files with 19 additions and 2 deletions

View File

@@ -26,7 +26,24 @@ Parfactor::Parfactor (
}
}
}
LogVar newLv = logVars.size();
constr_ = new ConstraintTree (logVars, tuples);
// Change formulas like f(X,X), X in {(p1),(p2),...}
// to be like f(X,Y), (X,Y) in {(p1,p1),(p2,p2),...}.
// This will simplify shattering on the constraint tree.
for (size_t i = 0; i < args_.size(); i++) {
LogVarSet lvSet;
LogVars& lvs = args_[i].logVars();
for (size_t j = 0; j < lvs.size(); j++) {
if (lvSet.contains (lvs[j]) == false) {
lvSet |= lvs[j];
} else {
constr_->cloneLogVar (lvs[j], newLv);
lvs[j] = newLv;
++ newLv;
}
}
}
assert (params_.size() == Util::sizeExpected (ranges_));
}