Hi all,
What would be a convenient way to compute a partial MAP in a Bayesian network using the junction tree algorithm? I managed to compute most probable explanations as follows:
std::vector<unsigned long int> get_mpe(dai::FactorGraph fg, std::vector<unsigned long int> evidence_vars, std::vector<unsigned long int> evidence_values)
{
std::vector<unsigned long int> mpe;
// set the evidence in the network
for (int i = 0; i < evidence_vars.size(); i++)
{
fg.clamp(evidence_vars[i], evidence_values[i], false);
}
dai::PropertySet opts;
dai::JTree jt = dai::JTree(fg, opts("updates",std::string("HUGIN"))("inference",std::string("MAXPROD")));
jt.init();
jt.run();
mpe = jt.findMaximum();
return mpe;
}
However, this computes the maximum over all non-clamped variables, and I'd like to compute the maximum over a subset of those, marginalizing over others. In short, compute $\argmax_{h} Pr(h, e) = \argmax_{h} \sum_{i} Pr(h, i, e)$ where we marginalize over all non-evidence, non-explanation variables.
thanks for your advise!
best
Johan