aGrUM  0.14.1
jointTargetedInference.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 #ifndef GUM_BAYES_NET_JOINT_TARGETED_INFERENCE_H
29 #define GUM_BAYES_NET_JOINT_TARGETED_INFERENCE_H
30 
31 
33 #include <agrum/agrum.h>
34 
35 
36 namespace gum {
37 
38 
53  template < typename GUM_SCALAR >
54  class JointTargetedInference : public MarginalTargetedInference< GUM_SCALAR > {
55  public:
56  // ############################################################################
58  // ############################################################################
60 
62 
64  explicit JointTargetedInference(const IBayesNet< GUM_SCALAR >* bn);
65 
67  virtual ~JointTargetedInference();
68 
70 
71 
72  // ############################################################################
74  // ############################################################################
76 
78 
92  virtual const Potential< GUM_SCALAR >&
93  jointPosterior(const NodeSet& nodes) final;
94 
96 
110  virtual const Potential< GUM_SCALAR >& posterior(NodeId node) final;
111 
113 
127  virtual const Potential< GUM_SCALAR >&
128  posterior(const std::string& nodeName) final;
130 
131 
132  // ############################################################################
134  // ############################################################################
136 
138 
144  virtual void eraseAllTargets();
145 
147  virtual void eraseAllJointTargets() final;
148 
150  virtual void eraseAllMarginalTargets() final;
151 
154 
157  virtual void addJointTarget(const NodeSet& joint_target) final;
158 
160 
162  virtual void eraseJointTarget(const NodeSet& joint_target) final;
163 
165  virtual bool isJointTarget(const NodeSet& vars) const final;
166 
168  virtual const Set< NodeSet >& jointTargets() const noexcept final;
169 
171  virtual Size nbrJointTargets() const noexcept final;
173 
185  Potential< GUM_SCALAR > evidenceJointImpact(const NodeSet& targets,
186  const NodeSet& evs);
187 
199  Potential< GUM_SCALAR >
200  evidenceJointImpact(const std::vector< std::string >& targets,
201  const std::vector< std::string >& evs);
202 
203  // ############################################################################
205  // ############################################################################
207 
215  GUM_SCALAR I(NodeId X, NodeId Y);
216 
224  GUM_SCALAR VI(NodeId X, NodeId Y);
225 
230  GUM_SCALAR jointMutualInformation(const NodeSet& targets);
231 
236  GUM_SCALAR jointMutualInformation(const std::vector< std::string >& targets);
237 
239 
240 
241  protected:
243  virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn);
244 
246 
247  virtual void _onJointTargetAdded(const NodeSet& set) = 0;
248 
250 
251  virtual void _onJointTargetErased(const NodeSet& set) = 0;
252 
254  virtual void _onAllTargetsErased() = 0;
255 
257  virtual void _onAllJointTargetsErased() = 0;
258 
259 
261 
263  virtual const Potential< GUM_SCALAR >& _jointPosterior(const NodeSet& set) = 0;
264 
272  virtual const Potential< GUM_SCALAR >&
273  _jointPosterior(const NodeSet& wanted_target,
274  const NodeSet& declared_target) = 0;
275 
280  virtual Potential< GUM_SCALAR >*
281  _unnormalizedJointPosterior(const NodeSet& set) = 0;
282 
284  virtual Potential< GUM_SCALAR >* _unnormalizedJointPosterior(NodeId id) = 0;
285 
286 
287  private:
290  };
291 
292 
293 } // namespace gum
294 
295 
296 #include <agrum/BN/inference/tools/jointTargetedInference_tpl.h>
297 
298 
299 #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
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual void _onJointTargetAdded(const NodeSet &set)=0
fired after a new joint target is inserted
This file contains the abstract inference class definition for computing (incrementally) marginal pos...
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:162
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:45
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:97