aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
BayesBall.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 The BayesBall algorithm (as described by Schachter).
25  *
26  * @author Lionel TORTI & Christophe GONZALES(@AMU) and Pierre-Henri
27  * WUILLEMIN(@LIP6)
28  */
29 
30 #ifndef GUM_BAYESBALLS_H
31 #define GUM_BAYESBALLS_H
32 
33 #include <utility>
34 
35 #include <agrum/agrum.h>
36 
37 #include <agrum/tools/core/hashTable.h>
38 #include <agrum/tools/core/list.h>
39 #include <agrum/tools/core/sequence.h>
40 
41 #include <agrum/BN/IBayesNet.h>
42 
43 namespace gum {
44  /**
45  * @class BayesBall
46  * @headerfile BayesBall.h <agrum/BN/inference/BayesBall.h>
47  * @brief Implementation of Shachter's Bayes Balls algorithm.
48  * @ingroup bn_inference
49  *
50  */
51  class BayesBall {
52  public:
53  // ############################################################################
54  /// @name Constructors / Destructors
55  // ############################################################################
56  /// @{
57  private:
58  /// Default constructor.
59  BayesBall();
60 
61  /// Destructor.
62  ~BayesBall();
63 
64  /// @}
65  public:
66  // ############################################################################
67  /// @name Accessors / Modifiers
68  // ############################################################################
69  /// @{
70 
71  /** @brief Fill the 'requisite' nodeset with the requisite nodes in dag
72  * given a query and evidence.
73  *
74  * Requisite nodes are those that are d-connected to at least one of the
75  * query nodes given a set of hard and soft evidence
76  */
77  static void requisiteNodes(const DAG& dag,
78  const NodeSet& query,
79  const NodeSet& hardEvidence,
80  const NodeSet& softEvidence,
81  NodeSet& requisite);
82 
83  /** @brief update a set of potentials, keeping only those d-connected with
84  * query variables given evidence */
85  template < typename GUM_SCALAR, template < typename > class TABLE >
86  static void relevantPotentials(const IBayesNet< GUM_SCALAR >& bn,
87  const NodeSet& query,
88  const NodeSet& hardEvidence,
89  const NodeSet& softEvidence,
90  Set< const TABLE< GUM_SCALAR >* >& potentials);
91 
92  /// @}
93  };
94 
95 } /* namespace gum */
96 
97 #ifndef GUM_NO_INLINE
98 # include <agrum/BN/algorithms/BayesBall_inl.h>
99 #endif // GUM_NO_INLINE
100 
101 #include <agrum/BN/algorithms/BayesBall_tpl.h>
102 
103 #endif /* GUM_BAYESBALLS_H */
BayesBall()
Default constructor.
Definition: BayesBall_inl.h:33
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
static void relevantPotentials(const IBayesNet< GUM_SCALAR > &bn, const NodeSet &query, const NodeSet &hardEvidence, const NodeSet &softEvidence, Set< const TABLE< GUM_SCALAR > * > &potentials)
update a set of potentials, keeping only those d-connected with query variables given evidence ...
Definition: BayesBall_tpl.h:33
Implementation of Shachter&#39;s Bayes Balls algorithm.
Definition: BayesBall.h:51
~BayesBall()
Destructor.
Definition: BayesBall_inl.h:39
static void requisiteNodes(const DAG &dag, const NodeSet &query, const NodeSet &hardEvidence, const NodeSet &softEvidence, NodeSet &requisite)
Fill the &#39;requisite&#39; nodeset with the requisite nodes in dag given a query and evidence.
Definition: BayesBall.cpp:35