64 template < GUM_Numeric GUM_SCALAR >
66 template < GUM_Numeric GUM_SCALAR >
90 template < GUM_Numeric GUM_SCALAR >
106 const
std::
string&
type() const noexcept;
183 std::unique_ptr< ASTtree< GUM_SCALAR > >
op1,
184 std::unique_ptr< ASTtree< GUM_SCALAR > >
op2);
198 std::
string toString(
std::string_view prefix =
"") const override;
217 ASTplus(std::unique_ptr< ASTtree< GUM_SCALAR > >
op1,
218 std::unique_ptr< ASTtree< GUM_SCALAR > >
op2);
222 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
236 template < GUM_Numeric GUM_SCALAR >
239 ASTminus(std::unique_ptr< ASTtree< GUM_SCALAR > >
op1,
240 std::unique_ptr< ASTtree< GUM_SCALAR > >
op2);
244 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
256 template < GUM_Numeric GUM_SCALAR >
259 ASTmult(std::unique_ptr< ASTtree< GUM_SCALAR > >
op1,
260 std::unique_ptr< ASTtree< GUM_SCALAR > >
op2);
264 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
276 template < GUM_Numeric GUM_SCALAR >
279 ASTdiv(std::unique_ptr< ASTtree< GUM_SCALAR > >
op1,
280 std::unique_ptr< ASTtree< GUM_SCALAR > >
op2);
284 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
303 template < GUM_Numeric GUM_SCALAR >
330 std::string
toString(std::string_view prefix =
"")
const override;
337 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
367 template < GUM_Numeric GUM_SCALAR >
377 std::string
toString(std::string_view prefix =
"")
const override;
384 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
403 template < GUM_Numeric GUM_SCALAR >
407 ASTsum(std::string_view
var, std::unique_ptr< ASTtree< GUM_SCALAR > >
term);
413 ASTsum(
const std::vector< std::string >& vars, std::unique_ptr< ASTtree< GUM_SCALAR > >
term);
416 [[nodiscard]]
const std::string&
var()
const;
419 const ASTtree< GUM_SCALAR >&
term()
const;
422 std::string
toString(std::string_view prefix =
"")
const override;
429 std::unique_ptr< ASTtree< GUM_SCALAR > >
copy()
const override;
435 std::unique_ptr< ASTtree< GUM_SCALAR > >
_term;
450 template < GUM_Numeric GUM_SCALAR >
451 std::unique_ptr< ASTtree< GUM_SCALAR > >
452 productOfTrees(std::vector< std::unique_ptr< ASTtree< GUM_SCALAR > > >&& lterms);
458#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
467 extern template std::unique_ptr< ASTtree< double > >
Class representing the minimal interface for Bayesian network with no numerical data.
ASTBinaryOp(std::string_view typ, std::unique_ptr< ASTtree< GUM_SCALAR > > op1, std::unique_ptr< ASTtree< GUM_SCALAR > > op2)
std::string toString(std::string_view prefix="") const override
Human-readable multi-line rendering (for debugging / logs).
const ASTtree< GUM_SCALAR > & op2() const
const ASTtree< GUM_SCALAR > & op1() const
std::unique_ptr< ASTtree< GUM_SCALAR > > _op2
std::unique_ptr< ASTtree< GUM_SCALAR > > _op1
ASTBinaryOp & operator=(const ASTBinaryOp &)=delete
ASTBinaryOp(ASTBinaryOp &&) noexcept=default
ASTBinaryOp(const ASTBinaryOp &)=delete
Elementwise division of two AST sub-expressions (left / right).
std::string fastToLatex(HashTable< std::string, int > &nameOccur) const override
Fast LaTeX rendering (lighter protection).
std::string protectToLatex(HashTable< std::string, int > &nameOccur) const override
LaTeX rendering with full name protection.
ASTdiv(std::unique_ptr< ASTtree< GUM_SCALAR > > op1, std::unique_ptr< ASTtree< GUM_SCALAR > > op2)
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const override
Deep clone of the sub-tree.
Joint probability term ( \mathbb{P}(\mathrm{vars}) ) in an observational BN.
std::string fastToLatex(HashTable< std::string, int > &nameOccur) const override
Fast LaTeX rendering (lighter protection).
ASTjointProba(const Set< std::string > &varNames)
Build a joint (\mathbb{P}(\mathrm{varNames})).
const Set< std::string > & varNames() const noexcept
std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const override
Deep clone of the sub-tree.
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.
Set< std::string > _varNames
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
Difference of two AST sub-expressions (left minus right).
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.
std::string protectToLatex(HashTable< std::string, int > &nameOccur) const override
LaTeX rendering with full name protection.
ASTminus(std::unique_ptr< ASTtree< GUM_SCALAR > > op1, std::unique_ptr< ASTtree< GUM_SCALAR > > op2)
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
Elementwise product of two AST sub-expressions.
std::string fastToLatex(HashTable< std::string, int > &nameOccur) const override
Fast LaTeX rendering (lighter protection).
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
ASTmult(std::unique_ptr< ASTtree< GUM_SCALAR > > op1, std::unique_ptr< ASTtree< GUM_SCALAR > > op2)
std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const override
Deep clone of the sub-tree.
std::string protectToLatex(HashTable< std::string, int > &nameOccur) const override
LaTeX rendering with full name protection.
Sum of two AST sub-expressions.
ASTplus(std::unique_ptr< ASTtree< GUM_SCALAR > > op1, std::unique_ptr< ASTtree< GUM_SCALAR > > op2)
Posterior probability term ( \mathbb{P}_{bn}(\mathrm{vars}\mid\mathrm{knw}) ).
std::string toString(std::string_view prefix="") const override
Human-readable multi-line rendering (for debugging / logs).
static void _ensure_nonempty(const Set< std::string > &vars)
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
Set< std::string > _vars
names of conditioned variables
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)
const Set< std::string > & knw() const noexcept
std::string fastToLatex(HashTable< std::string, int > &nameOccur) const override
Fast LaTeX rendering (lighter protection).
Set< std::string > _knw
names of conditioning variables (already minimalized)
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.
static Set< std::string > _compute_knw_from_bn(const DAGmodel &bn, const Set< std::string > &vars, const Set< std::string > &knw)
const Set< std::string > & vars() const noexcept
std::string protectToLatex(HashTable< std::string, int > &nameOccur) const override
LaTeX rendering with full name protection.
std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const override
Deep clone of the sub-tree.
Summation (marginalization) over one or more variables.
std::string _var
variable to eliminate
std::string protectToLatex(HashTable< std::string, int > &nameOccur) const override
LaTeX rendering with full name protection.
std::string toString(std::string_view prefix="") const override
Human-readable multi-line rendering (for debugging / logs).
Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const override
Evaluate the expression against a contextual BN.
std::string fastToLatex(HashTable< std::string, int > &nameOccur) const override
Fast LaTeX rendering (lighter protection).
std::unique_ptr< ASTtree< GUM_SCALAR > > _term
sub-expression
ASTsum(std::string_view var, std::unique_ptr< ASTtree< GUM_SCALAR > > term)
Single-variable summation ( \sum_{\text{var}} \text{term} ).
const ASTtree< GUM_SCALAR > & term() const
std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const override
Deep clone of the sub-tree.
const std::string & var() const
Root abstract node for the AST of algebraic expressions.
virtual std::string protectToLatex(HashTable< std::string, int > &nameOccur) const =0
LaTeX rendering with full name protection.
virtual std::unique_ptr< ASTtree< GUM_SCALAR > > copy() const =0
Deep clone of the sub-tree.
virtual std::string toString(std::string_view prefix="") const =0
Human-readable multi-line rendering (for debugging / logs).
ASTtree(ASTtree &&) noexcept
ASTtree & operator=(ASTtree &&) noexcept=default
virtual std::string fastToLatex(HashTable< std::string, int > &nameOccur) const =0
Fast LaTeX rendering (lighter protection).
ASTtree(std::string_view type)
Construct an AST node with a descriptive type string (used in dumps).
std::string toLatex(HashTable< std::string, int > nameOccur=HashTable< std::string, int >()) const
Convenience wrapper using an empty occurrence table.
static constexpr const char * CONTINUE_PREFIX
Prefix used to draw tree branches in toString.
static std::string _latexCorrect(std::string_view srcName, HashTable< std::string, int > &nameOccur)
Sanitize a single variable name for LaTeX and ensure uniqueness.
const std::string & type() const noexcept
ASTtree(const ASTtree &)=delete
virtual Tensor< GUM_SCALAR > eval(const IBayesNet< GUM_SCALAR > &contextual_bn) const =0
Evaluate the expression against a contextual BN.
ASTtree & operator=(const ASTtree &)=delete
Virtual base class for PGMs using a DAG.
The class for generic Hash Tables.
Class representing the minimal interface for Bayesian network with no numerical data.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Complete concept for GUM_SCALAR template parameter.
Template implementation of CausalModel/doAST.h.
gum is the global namespace for all aGrUM entities
std::unique_ptr< ASTtree< GUM_SCALAR > > productOfTrees(std::vector< std::unique_ptr< ASTtree< GUM_SCALAR > > > &<erms)
Build a product AST from a list of terms.
template std::unique_ptr< ASTtree< double > > productOfTrees< double >(std::vector< std::unique_ptr< ASTtree< double > > > &&)