41#ifndef GUM_CAUSAL_IMPACT_H
42#define GUM_CAUSAL_IMPACT_H
54 template < GUM_Numeric GUM_SCALAR >
56 template < GUM_Numeric GUM_SCALAR >
64 template < GUM_Numeric GUM_SCALAR >
81 template < GUM_Numeric GUM_SCALAR >
86 Tensor< GUM_SCALAR >
eval()
const;
92 std::string
toLatex(std::string_view doOperatorPrefix =
"do(",
93 std::string_view doOperatorSuffix =
")")
const;
99 std::string
latexQuery(std::string_view doOperatorPrefix =
"do(",
100 std::string_view doOperatorSuffix =
")")
const;
123 const ASTtree< GUM_SCALAR >&
root()
const;
130 const CausalFormula< GUM_SCALAR >&
getResult()
const;
143 std::vector< std::string >
onNames()
const;
145 std::vector< std::string >
doingNames()
const;
165 bool directDoCalculus =
false);
183 bool directDoCalculus =
false);
211 bool directDoCalculus);
217 bool directDoCalculus);
230 template < GUM_Numeric GUM_SCALAR >
236#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Builds a CausalFormula for a query (d-sep -> backdoor -> frontdoor -> (optional) do-calculus).
CausalImpact(CausalImpact &&)=default
static CausalFormula< GUM_SCALAR > _buildFromIds_(const CausalModel< GUM_SCALAR > &cm, const NodeSet &on, const NodeSet &doing, const NodeSet &knowing, bool directDoCalculus)
static bool _disjoint_(const Set< std::string > &a, const Set< std::string > &b, const Set< std::string > &c)
CausalFormula< GUM_SCALAR > _resultFormula_
Identified symbolic formula. If not identifiable, its AST may be nullptr and its explanation string (...
const NodeSet & on() const
std::string toLatex(std::string_view doOperatorPrefix="do(", std::string_view doOperatorSuffix=")") const
Generates a full LaTeX equation: Query = Formula.
const CausalFormula< GUM_SCALAR > & getResult() const
Access the underlying CausalFormula result.
static Set< std::string > _idsToNames_(const CausalModel< GUM_SCALAR > &cm, const NodeSet &ids)
std::string toString() const
Generates a string representation of the formula's AST.
std::vector< std::string > doingNames() const
Tensor< GUM_SCALAR > eval() const
Evaluates the formula's AST to compute the resulting probability distribution.
const ASTtree< GUM_SCALAR > & root() const
Access the root AST node of the identified formula.
CausalImpact(const CausalImpact &)=default
Copy/move constructors — defaulted; require CausalFormula to be copy/move-constructible.
CausalImpact(const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &on, const Set< std::string > &doing, const Set< std::string > &knowing=Set< std::string >(), bool directDoCalculus=false)
Constructs a CausalImpact object using variable names.
std::string latexQuery(std::string_view doOperatorPrefix="do(", std::string_view doOperatorSuffix=")") const
Generates a LaTeX representation of the original query, e.g., P(Y | do(X), Z).
const NodeSet & knowing() const
static CausalFormula< GUM_SCALAR > _buildFromNames_(const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &on, const Set< std::string > &doing, const Set< std::string > &knowing, bool directDoCalculus)
static NodeSet _namesToIds_(const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &names)
std::vector< std::string > onNames() const
Convenience: return names corresponding to stored node ids (sorted).
const NodeSet & doing() const
bool isIdentified() const noexcept
Whether the causal effect has been identified.
bool _directDoCalculus_
If true, skip backdoor/frontdoor and use do-calculus directly.
const std::string & explanation() const
std::vector< std::string > knowingNames() const
const CausalModel< GUM_SCALAR > & cm() const
A causal model pairing an observational BayesNet with a causal DAG.
Class for assigning/browsing values to tuples of discrete variables.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Do-calculus utilities and AST builders bound to a single CausalModel.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
Instantiation makeInstantiationFromValues(const Tensor< GUM_SCALAR > &tensor, const HashTable< std::string, std::string > &values)
Creates an instance for a tensor based on a HashTable.
std::tuple< CausalImpact< GUM_SCALAR >, Tensor< GUM_SCALAR >, std::string > causalImpact(const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &on, const Set< std::string > &doing, const Set< std::string > &knowing=Set< std::string >(), const HashTable< std::string, std::string > &values=HashTable< std::string, std::string >())
Standalone helper that mirrors the Python function causalImpact(...).