aGrUM  0.13.2
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 >
186  evidenceJointImpact(const std::vector< NodeId >& targets,
187  const std::vector< NodeId >& evs);
188 
200  Potential< GUM_SCALAR >
201  evidenceJointImpact(const std::vector< std::string >& targets,
202  const std::vector< std::string >& evs);
203 
204  // ############################################################################
206  // ############################################################################
208 
216  GUM_SCALAR I(NodeId X, NodeId Y);
217 
225  GUM_SCALAR VI(NodeId X, NodeId Y);
226 
228 
229 
230  protected:
232  virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn);
233 
235 
236  virtual void _onJointTargetAdded(const NodeSet& set) = 0;
237 
239 
240  virtual void _onJointTargetErased(const NodeSet& set) = 0;
241 
243  virtual void _onAllTargetsErased() = 0;
244 
246  virtual void _onAllJointTargetsErased() = 0;
247 
248 
250 
252  virtual const Potential< GUM_SCALAR >& _jointPosterior(const NodeSet& set) = 0;
253 
261  virtual const Potential< GUM_SCALAR >&
262  _jointPosterior(const NodeSet& wanted_target,
263  const NodeSet& declared_target) = 0;
264 
269  virtual Potential< GUM_SCALAR >*
270  _unnormalizedJointPosterior(const NodeSet& set) = 0;
271 
273  virtual Potential< GUM_SCALAR >* _unnormalizedJointPosterior(NodeId id) = 0;
274 
275 
276  private:
279  };
280 
281 
282 } // namespace gum
283 
284 
285 #include <agrum/BN/inference/tools/jointTargetedInference_tpl.h>
286 
287 
288 #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
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
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
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
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.
Potential< GUM_SCALAR > evidenceJointImpact(const std::vector< NodeId > &targets, const std::vector< NodeId > &evs)
Create a gum::Potential for P(joint targets|evs) (for all instanciation of targets and evs) ...
virtual const Potential< GUM_SCALAR > & jointPosterior(const NodeSet &nodes) final
Compute the joint posterior of a set of nodes.
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 const NodeSet & targets() const noexceptfinal
returns the list of marginal targets
virtual Size nbrJointTargets() const noexceptfinal
returns the number of joint targets
GUM_SCALAR VI(NodeId X, NodeId Y)
Variation of information between X and Y.
virtual const Set< NodeSet > & jointTargets() const noexceptfinal
returns the list of joint targets
virtual void _onJointTargetErased(const NodeSet &set)=0
fired before a joint target is removed
Set< NodeSet > __joint_targets
the set of joint targets