32 template <
typename GUM_SCALAR >
36 if (__inf !=
nullptr)
delete __inf;
39 for (
const auto pot : __obs)
46 template <
typename GUM_SCALAR >
51 std::stringstream var_name;
52 var_name << chain.first->
name() <<
"." << chain.second->safeName();
53 bn_obs->
add(__inf->BN().variableFromName(var_name.str()));
56 this->evidence(chain.first)[chain.second->id()];
59 for (i.setFirst(), j.
setFirst(); !i.end(); i.inc(), j.
inc()) {
60 bn_obs->
set(i, prm_obs->
get(j));
66 template <
typename GUM_SCALAR >
69 std::stringstream var_name;
70 var_name << chain.first->
name() <<
"." << chain.second->safeName();
73 for (
auto iter = __obs.beginSafe(); iter != __obs.endSafe();
75 if ((**iter).contains(var)) {
76 __inf->eraseEvidence(var_name.str());
85 template <
typename GUM_SCALAR >
93 template <
typename GUM_SCALAR >
102 template <
typename GUM_SCALAR >
108 template <
typename GUM_SCALAR >
118 template <
typename GUM_SCALAR >
126 template <
typename GUM_SCALAR >
134 std::stringstream sBuff;
136 if (!
__obs.empty()) {
137 for (
auto e :
__obs) {
139 __inf->addEvidence(*e);
144 sBuff << chain.first->
name() <<
"." << chain.second->safeName();
145 m =
__inf->posterior(
__inf->BN().idFromName(sBuff.str()));
148 template <
typename GUM_SCALAR >
155 template <
typename GUM_SCALAR >
157 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().
Headers of GroundedInference.
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>
gum is the global namespace for all aGrUM entities
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>