update groups when shattering
This commit is contained in:
parent
bb5d02dbc0
commit
cd720497f8
@ -229,9 +229,8 @@ ParfactorList::shatter (
|
|||||||
// cout << g2->constr()->tupleSet (f2.logVars()) << endl;
|
// cout << g2->constr()->tupleSet (f2.logVars()) << endl;
|
||||||
// Util::printDashedLine();
|
// Util::printDashedLine();
|
||||||
if (f1.isAtom()) {
|
if (f1.isAtom()) {
|
||||||
unsigned group = (f1.group() < f2.group()) ? f1.group() : f2.group();
|
f2.setGroup (f1.group());
|
||||||
f1.setGroup (group);
|
updateGroups (f2.group(), f1.group());
|
||||||
f2.setGroup (group);
|
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
assert (g1->constr()->empty() == false);
|
assert (g1->constr()->empty() == false);
|
||||||
@ -279,13 +278,9 @@ ParfactorList::shatter (
|
|||||||
// exclCt2->exportToGraphViz (ss6.str().c_str(), true);
|
// exclCt2->exportToGraphViz (ss6.str().c_str(), true);
|
||||||
|
|
||||||
if (exclCt1->empty() && exclCt2->empty()) {
|
if (exclCt1->empty() && exclCt2->empty()) {
|
||||||
unsigned group = (f1.group() < f2.group())
|
|
||||||
? f1.group()
|
|
||||||
: f2.group();
|
|
||||||
// identical
|
// identical
|
||||||
f1.setGroup (group);
|
f2.setGroup (f1.group());
|
||||||
f2.setGroup (group);
|
updateGroups (f2.group(), f1.group());
|
||||||
// unifyGroups
|
|
||||||
delete commCt1;
|
delete commCt1;
|
||||||
delete exclCt1;
|
delete exclCt1;
|
||||||
delete commCt2;
|
delete commCt2;
|
||||||
@ -361,15 +356,13 @@ ParfactorList::shatter (
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParfactorList::unifyGroups (unsigned group1, unsigned group2)
|
ParfactorList::updateGroups (unsigned oldGroup, unsigned newGroup)
|
||||||
{
|
{
|
||||||
unsigned newGroup = ProbFormula::getNewGroup();
|
|
||||||
for (ParfactorList::iterator it = pfList_.begin();
|
for (ParfactorList::iterator it = pfList_.begin();
|
||||||
it != pfList_.end(); it++) {
|
it != pfList_.end(); it++) {
|
||||||
ProbFormulas& formulas = (*it)->arguments();
|
ProbFormulas& formulas = (*it)->arguments();
|
||||||
for (unsigned i = 0; i < formulas.size(); i++) {
|
for (unsigned i = 0; i < formulas.size(); i++) {
|
||||||
if (formulas[i].group() == group1 ||
|
if (formulas[i].group() == oldGroup) {
|
||||||
formulas[i].group() == group2) {
|
|
||||||
formulas[i].setGroup (newGroup);
|
formulas[i].setGroup (newGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +396,7 @@ ParfactorList::identical (
|
|||||||
c1.moveToTop (f1.logVars());
|
c1.moveToTop (f1.logVars());
|
||||||
c2.moveToTop (f2.logVars());
|
c2.moveToTop (f2.logVars());
|
||||||
return ConstraintTree::identical (
|
return ConstraintTree::identical (
|
||||||
&c1, &c2, f1.logVars().size());
|
&c1, &c2, f1.arity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -421,7 +414,7 @@ ParfactorList::disjoint (
|
|||||||
}
|
}
|
||||||
c1.moveToTop (f1.logVars());
|
c1.moveToTop (f1.logVars());
|
||||||
c2.moveToTop (f2.logVars());
|
c2.moveToTop (f2.logVars());
|
||||||
return ConstraintTree::overlap (
|
return ConstraintTree::disjoint (
|
||||||
&c1, &c2, f1.arity()) == false;
|
&c1, &c2, f1.arity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class ParfactorList
|
|||||||
ConstraintTree*,
|
ConstraintTree*,
|
||||||
unsigned);
|
unsigned);
|
||||||
|
|
||||||
void unifyGroups (unsigned group1, unsigned group2);
|
void updateGroups (unsigned group1, unsigned group2);
|
||||||
|
|
||||||
bool proper (
|
bool proper (
|
||||||
const ProbFormula&, ConstraintTree,
|
const ProbFormula&, ConstraintTree,
|
||||||
|
Reference in New Issue
Block a user