/** * Calc Node Score With Parent Deleted * * @param nNode node for which the score is calculate * @param nCandidateParent candidate parent to delete from the existing parent set * @return log score */ public double calcScoreWithMissingParent(int nNode, int nCandidateParent) { ParentSet oParentSet = m_BayesNet.getParentSet(nNode); // sanity check: nCandidateParent should be in parent set already if (!oParentSet.contains(nCandidateParent)) { return -1e100; } // set up candidate parent int iParent = oParentSet.deleteParent(nCandidateParent, m_BayesNet.m_Instances); // calculate the score double logScore = calcNodeScore(nNode); // restore temporarily deleted parent oParentSet.addParent(nCandidateParent, iParent, m_BayesNet.m_Instances); return logScore; } // CalcScoreWithMissingParent
/** * Calc Node Score With AddedParent * * @param nNode node for which the score is calculate * @param nCandidateParent candidate parent to add to the existing parent set * @return log score */ public double calcScoreWithExtraParent(int nNode, int nCandidateParent) { ParentSet oParentSet = m_BayesNet.getParentSet(nNode); // sanity check: nCandidateParent should not be in parent set already if (oParentSet.contains(nCandidateParent)) { return -1e100; } // set up candidate parent oParentSet.addParent(nCandidateParent, m_BayesNet.m_Instances); // calculate the score double logScore = calcNodeScore(nNode); // delete temporarily added parent oParentSet.deleteLastParent(m_BayesNet.m_Instances); return logScore; } // CalcScoreWithExtraParent