assign evidence to the pruned factor graph
This commit is contained in:
parent
b27500e93f
commit
0d5888e238
@ -14,7 +14,6 @@ FactorGraph*
|
|||||||
BayesBall::getMinimalFactorGraph (const VarIds& queryIds)
|
BayesBall::getMinimalFactorGraph (const VarIds& queryIds)
|
||||||
{
|
{
|
||||||
assert (fg_.isFromBayesNetwork());
|
assert (fg_.isFromBayesNetwork());
|
||||||
|
|
||||||
Scheduling scheduling;
|
Scheduling scheduling;
|
||||||
for (unsigned i = 0; i < queryIds.size(); i++) {
|
for (unsigned i = 0; i < queryIds.size(); i++) {
|
||||||
assert (dag_.getNode (queryIds[i]));
|
assert (dag_.getNode (queryIds[i]));
|
||||||
@ -64,7 +63,7 @@ BayesBall::constructGraph (FactorGraph* fg) const
|
|||||||
const DAGraphNode* n = dag_.getNode (
|
const DAGraphNode* n = dag_.getNode (
|
||||||
facNodes[i]->factor().argument (0));
|
facNodes[i]->factor().argument (0));
|
||||||
if (n->isMarkedOnTop()) {
|
if (n->isMarkedOnTop()) {
|
||||||
fg->addFactor (Factor (facNodes[i]->factor()));
|
fg->addFactor (facNodes[i]->factor());
|
||||||
} else if (n->hasEvidence() && n->isVisited()) {
|
} else if (n->hasEvidence() && n->isVisited()) {
|
||||||
VarIds varIds = { facNodes[i]->factor().argument (0) };
|
VarIds varIds = { facNodes[i]->factor().argument (0) };
|
||||||
Ranges ranges = { facNodes[i]->factor().range (0) };
|
Ranges ranges = { facNodes[i]->factor().range (0) };
|
||||||
@ -73,5 +72,14 @@ BayesBall::constructGraph (FactorGraph* fg) const
|
|||||||
fg->addFactor (Factor (varIds, ranges, params));
|
fg->addFactor (Factor (varIds, ranges, params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const VarNodes& varNodes = fg_.varNodes();
|
||||||
|
for (unsigned i = 0; i < varNodes.size(); i++) {
|
||||||
|
if (varNodes[i]->hasEvidence()) {
|
||||||
|
VarNode* vn = fg->getVarNode (varNodes[i]->varId());
|
||||||
|
if (vn) {
|
||||||
|
vn->setEvidence (varNodes[i]->getEvidence());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user