![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Posterior probability term ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ). More...
#include <doAST.h>
Public Member Functions | |
| ASTposteriorProba (const DAGmodel &bn, const Set< std::string > &vars, const Set< std::string > &knw) | |
| Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ); knw will be minimalized using bn. | |
| ASTposteriorProba (const DAG &bn, const Bijection< NodeId, std::string > &id2name, const Set< std::string > &vars, const Set< std::string > &knw) | |
| Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ); knw will be minimalized using dag. | |
| ASTposteriorProba (const Set< std::string > &vars, const Set< std::string > &knw) | |
| Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ) with already minimalized knw. | |
| const Set< std::string > & | vars () const noexcept |
| const Set< std::string > & | knw () const noexcept |
| std::string | toString (std::string_view prefix="") const override |
| Human-readable multi-line rendering (for debugging / logs). | |
| std::string | protectToLatex (HashTable< std::string, int > &nameOccur) const override |
| LaTeX rendering with full name protection. | |
| std::string | fastToLatex (HashTable< std::string, int > &nameOccur) const override |
| Fast LaTeX rendering (lighter protection). | |
| std::unique_ptr< ASTtree< GUM_SCALAR > > | copy () const override |
| Deep clone of the sub-tree. | |
| Tensor< GUM_SCALAR > | eval (const IBayesNet< GUM_SCALAR > &contextual_bn) const override |
| Evaluate the expression against a contextual BN. | |
| const std::string & | type () const noexcept |
| std::string | toLatex (HashTable< std::string, int > nameOccur=HashTable< std::string, int >()) const |
| Convenience wrapper using an empty occurrence table. | |
Static Protected Member Functions | |
| static std::string | _latexCorrect (std::string_view srcName, HashTable< std::string, int > &nameOccur) |
| Sanitize a single variable name for LaTeX and ensure uniqueness. | |
| static std::vector< std::string > | _latexCorrect (const Set< std::string > &srcNames, HashTable< std::string, int > &nameOccur) |
| Sanitize a set of variable names for LaTeX and ensure uniqueness. | |
Protected Attributes | |
| std::string | _type |
Static Protected Attributes | |
| static constexpr const char * | CONTINUE_PREFIX = "| " |
| Prefix used to draw tree branches in toString. | |
Static Private Member Functions | |
| static void | _ensure_nonempty (const Set< std::string > &vars) |
| static Set< std::string > | _compute_knw_from_bn (const DAGmodel &bn, const Set< std::string > &vars, const Set< std::string > &knw) |
| static Set< std::string > | _compute_knw_from_dag (const DAG &dag, const Bijection< NodeId, std::string > &id2name, const Set< std::string > &vars, const Set< std::string > &knw) |
Private Attributes | |
| Set< std::string > | _vars |
| names of conditioned variables | |
| Set< std::string > | _knw |
| names of conditioning variables (already minimalized) | |
Posterior probability term ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ).
Two construction modes are provided:
eval queries the contextual BN and returns the corresponding posterior tensor.
|
explicit |
Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ); knw will be minimalized using bn.
Definition at line 258 of file doAST_tpl.h.
References ASTposteriorProba(), _compute_knw_from_bn(), knw(), and vars().
Referenced by ASTposteriorProba(), and ASTposteriorProba().
|
explicit |
Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ); knw will be minimalized using dag.
Definition at line 264 of file doAST_tpl.h.
References ASTposteriorProba(), _compute_knw_from_dag(), knw(), and vars().
|
explicit |
Constructor for ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ) with already minimalized knw.
Definition at line 272 of file doAST_tpl.h.
References gum::ASTtree< GUM_SCALAR >::ASTtree(), _ensure_nonempty(), _knw, _vars, knw(), and vars().
|
staticprivate |
Definition at line 411 of file doAST_tpl.h.
References gum::DiscreteGraphicalModel::idFromName(), gum::Set< Key >::insert(), knw(), gum::DAGmodel::minimalCondSet(), gum::Variable::name(), gum::DiscreteGraphicalModel::variable(), and vars().
Referenced by ASTposteriorProba().
|
staticprivate |
Definition at line 427 of file doAST_tpl.h.
References gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::first(), gum::Set< Key >::insert(), knw(), gum::DAG::minimalCondSet(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::second(), and vars().
Referenced by ASTposteriorProba().
|
staticprivate |
Definition at line 405 of file doAST_tpl.h.
References GUM_ERROR, and vars().
Referenced by ASTposteriorProba().
|
staticprotectedinherited |
Sanitize a set of variable names for LaTeX and ensure uniqueness.
Definition at line 89 of file doAST_tpl.h.
References _latexCorrect().
|
staticprotectedinherited |
Sanitize a single variable name for LaTeX and ensure uniqueness.
Definition at line 79 of file doAST_tpl.h.
References gum::HashTable< Key, Val >::getWithDefault().
Referenced by _latexCorrect(), gum::ASTjointProba< GUM_SCALAR >::fastToLatex(), gum::ASTposteriorProba< GUM_SCALAR >::fastToLatex(), gum::ASTsum< GUM_SCALAR >::fastToLatex(), gum::ASTjointProba< GUM_SCALAR >::toString(), and gum::ASTposteriorProba< GUM_SCALAR >::toString().
|
overridevirtual |
Deep clone of the sub-tree.
Implements gum::ASTtree< GUM_SCALAR >.
Definition at line 360 of file doAST_tpl.h.
|
overridevirtual |
Evaluate the expression against a contextual BN.
| contextual_bn | Bayesian network providing CPTs and variable domains |
Implements gum::ASTtree< GUM_SCALAR >.
Definition at line 367 of file doAST_tpl.h.
References _knw, _vars, gum::JointTargetedInference< GUM_SCALAR >::addJointTarget(), gum::IBayesNet< GUM_SCALAR >::cpt(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::DiscreteGraphicalModel::idFromName(), gum::Set< Key >::insert(), gum::JointTargetedInference< GUM_SCALAR >::jointPosterior(), gum::GraphicalModelInference< GUM_SCALAR >::makeInference(), and gum::DAGmodel::parents().
|
overridevirtual |
Fast LaTeX rendering (lighter protection).
Assumes prior hygiene of names; typically avoids heavier bookkeeping performed in protectToLatex.
| nameOccur | symbol occurrence table (may be consulted/updated) |
Implements gum::ASTtree< GUM_SCALAR >.
Definition at line 329 of file doAST_tpl.h.
References _knw, gum::ASTtree< GUM_SCALAR >::_latexCorrect(), and _vars.
Referenced by protectToLatex().
|
noexcept |
Definition at line 284 of file doAST_tpl.h.
References _knw.
Referenced by ASTposteriorProba(), ASTposteriorProba(), ASTposteriorProba(), _compute_knw_from_bn(), and _compute_knw_from_dag().
|
overridevirtual |
LaTeX rendering with full name protection.
Produces LaTeX with variable-name disambiguation, using nameOccur as a registry of encountered names and their occurrence counts.
| nameOccur | symbol occurrence table (updated in place) |
Implements gum::ASTtree< GUM_SCALAR >.
Definition at line 322 of file doAST_tpl.h.
References fastToLatex().
|
inherited |
Convenience wrapper using an empty occurrence table.
Definition at line 73 of file doAST_tpl.h.
References fastToLatex().
Referenced by fastToLatex().
|
overridevirtual |
Human-readable multi-line rendering (for debugging / logs).
| prefix | indentation prefix propagated to children |
Implements gum::ASTtree< GUM_SCALAR >.
Definition at line 289 of file doAST_tpl.h.
References _knw, gum::ASTtree< GUM_SCALAR >::_latexCorrect(), and _vars.
|
noexceptinherited |
Definition at line 68 of file doAST_tpl.h.
References _type.
Referenced by gum::ASTBinaryOp< GUM_SCALAR >::ASTBinaryOp(), ASTtree(), and operator=().
|
noexcept |
Definition at line 279 of file doAST_tpl.h.
References _vars.
Referenced by ASTposteriorProba(), ASTposteriorProba(), ASTposteriorProba(), _compute_knw_from_bn(), _compute_knw_from_dag(), and _ensure_nonempty().
|
private |
names of conditioning variables (already minimalized)
Definition at line 343 of file doAST.h.
Referenced by ASTposteriorProba(), copy(), eval(), fastToLatex(), knw(), and toString().
|
protectedinherited |
Definition at line 154 of file doAST.h.
Referenced by ASTtree(), gum::ASTBinaryOp< GUM_SCALAR >::toString(), and type().
|
private |
names of conditioned variables
Definition at line 342 of file doAST.h.
Referenced by ASTposteriorProba(), copy(), eval(), fastToLatex(), toString(), and vars().
|
staticconstexprprotectedinherited |
Prefix used to draw tree branches in toString.
Definition at line 153 of file doAST.h.
Referenced by gum::ASTBinaryOp< GUM_SCALAR >::toString(), and gum::ASTsum< GUM_SCALAR >::toString().