aGrUM  0.16.0
jointTargetedInference.h
Go to the documentation of this file.
1 
31 #ifndef GUM_BAYES_NET_JOINT_TARGETED_INFERENCE_H
32 #define GUM_BAYES_NET_JOINT_TARGETED_INFERENCE_H
33 
34 
36 #include <agrum/agrum.h>
37 
38 
39 namespace gum {
40 
41 
56  template < typename GUM_SCALAR >
57  class JointTargetedInference : public MarginalTargetedInference< GUM_SCALAR > {
58  public:
59  // ############################################################################
61  // ############################################################################
63 
65 
67  explicit JointTargetedInference(const IBayesNet< GUM_SCALAR >* bn);
68 
70  virtual ~JointTargetedInference();
71 
73 
74 
75  // ############################################################################
77  // ############################################################################
79 
81 
95  virtual const Potential< GUM_SCALAR >&
96  jointPosterior(const NodeSet& nodes) final;
97 
99 
113  virtual const Potential< GUM_SCALAR >& posterior(NodeId node) final;
114 
116 
130  virtual const Potential< GUM_SCALAR >&
131  posterior(const std::string& nodeName) final;
133 
134 
135  // ############################################################################
137  // ############################################################################
139 
141 
147  virtual void eraseAllTargets();
148 
150  virtual void eraseAllJointTargets() final;
151 
153  virtual void eraseAllMarginalTargets() final;
154 
157 
160  virtual void addJointTarget(const NodeSet& joint_target) final;
161 
163 
165  virtual void eraseJointTarget(const NodeSet& joint_target) final;
166 
168  virtual bool isJointTarget(const NodeSet& vars) const final;
169 
171  virtual const Set< NodeSet >& jointTargets() const noexcept final;
172 
174  virtual Size nbrJointTargets() const noexcept final;
176 
188  Potential< GUM_SCALAR > evidenceJointImpact(const NodeSet& targets,
189  const NodeSet& evs);
190 
202  Potential< GUM_SCALAR >
203  evidenceJointImpact(const std::vector< std::string >& targets,
204  const std::vector< std::string >& evs);
205 
206  // ############################################################################
208  // ############################################################################
210 
218  GUM_SCALAR I(NodeId X, NodeId Y);
219 
227  GUM_SCALAR VI(NodeId X, NodeId Y);
228 
233  GUM_SCALAR jointMutualInformation(const NodeSet& targets);
234 
239  GUM_SCALAR jointMutualInformation(const std::vector< std::string >& targets);
240 
242 
243 
244  protected:
246  virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn);
247 
249 
250  virtual void _onJointTargetAdded(const NodeSet& set) = 0;
251 
253 
254  virtual void _onJointTargetErased(const NodeSet& set) = 0;
255 
257  virtual void _onAllTargetsErased() = 0;
258 
260  virtual void _onAllJointTargetsErased() = 0;
261 
262 
264 
266  virtual const Potential< GUM_SCALAR >& _jointPosterior(const NodeSet& set) = 0;
267 
275  virtual const Potential< GUM_SCALAR >&
276  _jointPosterior(const NodeSet& wanted_target,
277  const NodeSet& declared_target) = 0;
278 
283  virtual Potential< GUM_SCALAR >*
284  _unnormalizedJointPosterior(const NodeSet& set) = 0;
285 
287  virtual Potential< GUM_SCALAR >* _unnormalizedJointPosterior(NodeId id) = 0;
288 
289 
290  private:
293  };
294 
295 
296 } // namespace gum
297 
298 
299 #include <agrum/BN/inference/tools/jointTargetedInference_tpl.h>
300 
301 
302 #endif // GUM_BAYES_NET_JOINT_TARGETED_INFERENCE_H
virtual void eraseAllMarginalTargets() final
Clear all the previously defined marginal targets.
virtual void eraseAllTargets()
Clear all previously defined targets (marginal and joint targets)
virtual void addJointTarget(const NodeSet &joint_target) final
Add a set of nodes as a new joint target. As a collateral effect, every node is added as a marginal t...
virtual ~JointTargetedInference()
destructor
JointTargetedInference(const IBayesNet< GUM_SCALAR > *bn)
default constructor
GUM_SCALAR I(NodeId X, NodeId Y)
Mutual information between X and Y.
virtual void _onAllJointTargetsErased()=0
fired before a all the joint targets are removed
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
virtual bool isJointTarget(const NodeSet &vars) const final
return true if target is a joint target.
STL namespace.
virtual void _onAllTargetsErased()=0
fired before a all the marginal and joint targets are removed
virtual Potential< GUM_SCALAR > * _unnormalizedJointPosterior(const NodeSet &set)=0
returns a fresh unnormalized joint posterior of a given set of variables
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual void _onJointTargetAdded(const NodeSet &set)=0
fired after a new joint target is inserted
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void eraseJointTarget(const NodeSet &joint_target) final
removes an existing joint target
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
virtual void eraseAllJointTargets() final
Clear all previously defined joint targets.
virtual const Set< NodeSet > & jointTargets() const noexcept final
returns the list of joint targets
virtual const Potential< GUM_SCALAR > & jointPosterior(const NodeSet &nodes) final
Compute the joint posterior of a set of nodes.
Potential< GUM_SCALAR > evidenceJointImpact(const NodeSet &targets, const NodeSet &evs)
Create a gum::Potential for P(joint targets|evs) (for all instanciation of targets and evs) ...
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR > *bn)
fired after a new Bayes net has been assigned to the engine
virtual const Potential< GUM_SCALAR > & _jointPosterior(const NodeSet &set)=0
asks derived classes for the joint posterior of a declared target set
virtual const Potential< GUM_SCALAR > & posterior(NodeId node) final
Computes and returns the posterior of a node.
virtual Size nbrJointTargets() const noexcept final
returns the number of joint targets
virtual const NodeSet & targets() const noexcept final
returns the list of marginal targets
GUM_SCALAR jointMutualInformation(const NodeSet &targets)
Mutual information between targets.
GUM_SCALAR VI(NodeId X, NodeId Y)
Variation of information between X and Y.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
virtual void _onJointTargetErased(const NodeSet &set)=0
fired before a joint target is removed
Set< NodeSet > __joint_targets
the set of joint targets
Size NodeId
Type for node ids.
Definition: graphElements.h:98