aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
influenceDiagramInference.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief This file contains abstract class definitions influence diagrams
25  * inference classes.
26  *
27  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
28  * GONZALES(@AMU)
29  */
30 
31 #ifndef GUM_INFLUENCE_DIAGRAM_INFERENCE_H
32 #define GUM_INFLUENCE_DIAGRAM_INFERENCE_H
33 
34 #include <agrum/ID/influenceDiagram.h>
35 #include <agrum/tools/graphicalModels/inference/graphicalModelInference.h>
36 
37 namespace gum {
38  /**
39  * @class InfluenceDiagramInference InfluenceDiagramInference.h
40  *<agrum/ID/inference/influenceDiagramInference.h>
41  * @brief Abstract base class for inference engines in influence diagrams.
42  * @ingroup id_group
43  *
44  */
45  template < typename GUM_SCALAR >
47  public:
48  /**
49  * Default constructor
50  */
51  explicit InfluenceDiagramInference(const InfluenceDiagram< GUM_SCALAR >* infDiag);
52 
53  /**
54  * Destructor.
55  */
56  virtual ~InfluenceDiagramInference();
57 
58  /// assigns a new influence diagram to the inference engine
59  /** Assigns a new influence diagram to the o,fere,ce e,go,e engine and sends
60  * messages to the descendants of ShaferShenoyLIMIDInference to inform them
61  * that the ID has changed.
62  * @warning note that, by aGrUM's rule, the influence Diagram is not copied
63  * into the inference engine but only referenced. */
64  virtual void setInfluenceDiagram(const InfluenceDiagram< GUM_SCALAR >* infdiag);
65 
66  /// Returns a constant reference over the IBayesNet referenced by this class
67  /** @throws UndefinedElement is raised if no Bayes net has been assigned to
68  * the inference. */
69  virtual const InfluenceDiagram< GUM_SCALAR >& influenceDiagram() const final;
70 
72  virtual gum::Potential< GUM_SCALAR > optimalDecision(const std::string& nodename) = 0;
73 
74  virtual const Potential< GUM_SCALAR >& posterior(NodeId node) = 0;
75  virtual const Potential< GUM_SCALAR >& posterior(const std::string& nodename) = 0;
76 
77  virtual const Potential< GUM_SCALAR >& posteriorUtility(NodeId node) = 0;
78  virtual const Potential< GUM_SCALAR >& posteriorUtility(const std::string& nodename) = 0;
79 
80  virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(NodeId node) = 0;
81  virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(const std::string& nodename) = 0;
82 
83  virtual std::pair< GUM_SCALAR, GUM_SCALAR > MEU() = 0;
84 
85  private:
86  /// assigns a influence diagram during the inference engine construction
87  void _setIDDuringConstruction_(const InfluenceDiagram< GUM_SCALAR >* infdiag);
88  };
89 
90 } /* namespace gum */
91 
92 #include <agrum/ID/inference/tools/influenceDiagramInference_tpl.h>
93 
94 #endif /* GUM_INFLUENCE_DIAGRAM_INFERENCE_H */
virtual gum::Potential< GUM_SCALAR > optimalDecision(NodeId decisionId)=0
<agrum/ID/inference/influenceDiagramInference.h>
virtual const Potential< GUM_SCALAR > & posteriorUtility(NodeId node)=0
virtual const InfluenceDiagram< GUM_SCALAR > & influenceDiagram() const final
Returns a constant reference over the IBayesNet referenced by this class.
void _setIDDuringConstruction_(const InfluenceDiagram< GUM_SCALAR > *infdiag)
assigns a influence diagram during the inference engine construction
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual std::pair< GUM_SCALAR, GUM_SCALAR > MEU()=0
InfluenceDiagramInference(const InfluenceDiagram< GUM_SCALAR > *infDiag)
Default constructor.
virtual const Potential< GUM_SCALAR > & posterior(NodeId node)=0
virtual const Potential< GUM_SCALAR > & posteriorUtility(const std::string &nodename)=0
virtual const Potential< GUM_SCALAR > & posterior(const std::string &nodename)=0
virtual ~InfluenceDiagramInference()
Destructor.
virtual void setInfluenceDiagram(const InfluenceDiagram< GUM_SCALAR > *infdiag)
assigns a new influence diagram to the inference engine
virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(const std::string &nodename)=0
virtual gum::Potential< GUM_SCALAR > optimalDecision(const std::string &nodename)=0
virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(NodeId node)=0