35 template <
typename GUM_SCALAR >
39 if (__inf !=
nullptr)
delete __inf;
42 for (
const auto pot : __obs)
49 template <
typename GUM_SCALAR >
54 std::stringstream var_name;
55 var_name << chain.first->
name() <<
"." << chain.second->safeName();
56 bn_obs->
add(__inf->BN().variableFromName(var_name.str()));
59 this->evidence(chain.first)[chain.second->id()];
62 for (i.setFirst(), j.
setFirst(); !i.end(); i.inc(), j.
inc()) {
63 bn_obs->
set(i, prm_obs->
get(j));
69 template <
typename GUM_SCALAR >
72 std::stringstream var_name;
73 var_name << chain.first->
name() <<
"." << chain.second->safeName();
76 for (
auto iter = __obs.beginSafe(); iter != __obs.endSafe();
78 if ((**iter).contains(var)) {
79 __inf->eraseEvidence(var_name.str());
88 template <
typename GUM_SCALAR >
96 template <
typename GUM_SCALAR >
105 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
121 template <
typename GUM_SCALAR >
129 template <
typename GUM_SCALAR >
137 std::stringstream sBuff;
139 if (!
__obs.empty()) {
140 for (
auto e :
__obs) {
142 __inf->addEvidence(*e);
147 sBuff << chain.first->
name() <<
"." << chain.second->safeName();
148 m =
__inf->posterior(
__inf->BN().idFromName(sBuff.str()));
151 template <
typename GUM_SCALAR >
158 template <
typename GUM_SCALAR >
160 return "grounded inference";
aGrUM's Potential is a multi-dimensional array with tensor operators.
MarginalTargetedInference< GUM_SCALAR > * __inf
The bayesnet inference engine used by this class.
virtual void _evidenceRemoved(const typename PRMInference< GUM_SCALAR >::Chain &chain)
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference...
virtual void _joint(const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &queries, Potential< GUM_SCALAR > &j)
Generic method to compute the marginal of given element.
virtual GUM_SCALAR get(const Instantiation &i) const final
Default implementation of MultiDimContainer::get().
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual std::string name() const
Returns the bayesnet inference engine used by this class.
virtual void erase(const DiscreteVariable &var) final
Removes a var from the variables of the multidimensional matrix.
virtual void _marginal(const typename PRMInference< GUM_SCALAR >::Chain &chain, Potential< GUM_SCALAR > &m)
Generic method to compute the marginal of given element.
Base class for discrete random variable.
<agrum/BN/inference/marginalTargetedInference.h>
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~GroundedInference()
Destructor.
void inc()
Operator increment.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
MarginalTargetedInference< GUM_SCALAR > & getBNInference()
Returns the bayesnet inference engine used by this class.
GroundedInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system)
Default constructor.
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Class for assigning/browsing values to tuples of discrete variables.
GroundedInference & operator=(const GroundedInference &source)
Copy operator.
virtual void add(const DiscreteVariable &v) final
Adds a new var to the variables of the multidimensional matrix.
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
virtual void _evidenceAdded(const typename PRMInference< GUM_SCALAR >::Chain &chain)
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference...
List< const Potential< GUM_SCALAR > *> __obs
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const final
Default implementation of MultiDimContainer::set().
void setFirst()
Assign the first values to the tuple of the Instantiation.
virtual std::string name() const =0
Returns the name of the current inference algorithm.
void setBNInference(MarginalTargetedInference< GUM_SCALAR > *bn_inf)
Defines the bayesnet inference engine used by this class.
#define GUM_ERROR(type, msg)
<agrum/PRM/groundedInference.h>