33 #include <agrum/tools/core/hashTable.h> 34 #include <agrum/tools/core/set.h> 36 #include <agrum/PRM/PRM.h> 37 #include <agrum/PRM/inference/PRMInference.h> 39 #ifndef GUM_STRUCTURED_BB_H 40 # define GUM_STRUCTURED_BB_H 49 template <
typename GUM_SCALAR >
50 class StructuredBayesBall {
58 StructuredBayesBall(
const PRMInference< GUM_SCALAR >& inference);
61 ~StructuredBayesBall();
70 const std::string& key(
const PRMInstance< GUM_SCALAR >* i)
const;
73 const std::string& key(
const PRMInstance< GUM_SCALAR >& i)
const;
76 const Set< NodeId >& requisiteNodes(
const PRMInstance< GUM_SCALAR >* i)
const;
79 const Set< NodeId >& requisiteNodes(
const PRMInstance< GUM_SCALAR >& i)
const;
83 Size occurrence(
const std::string& key)
const;
87 float liftRatio()
const;
90 bool exists(
const PRMInstance< GUM_SCALAR >* i)
const;
93 bool exists(
const PRMInstance< GUM_SCALAR >& i)
const;
100 void compute(
const PRMInstance< GUM_SCALAR >* i, NodeId n);
105 void compute(
const PRMInstance< GUM_SCALAR >& i, NodeId n);
108 bool _isHardEvidence_(
const PRMInstance< GUM_SCALAR >* i, NodeId n);
112 StructuredBayesBall(
const StructuredBayesBall& source);
115 StructuredBayesBall& operator=(
const StructuredBayesBall& source);
118 typedef HashTable< NodeId, std::pair<
bool,
bool > > MarkMap;
120 typedef HashTable<
const PRMInstance< GUM_SCALAR >*, MarkMap* > InstanceMap;
122 std::pair<
bool,
bool >&
123 _getMark_(InstanceMap& marks,
const PRMInstance< GUM_SCALAR >* i, NodeId n);
125 const PRMSlotChain< GUM_SCALAR >& _getSC_(
const PRMInstance< GUM_SCALAR >* i, NodeId n);
131 void _compute_(
const PRMInstance< GUM_SCALAR >* i, NodeId n);
134 void _fromChild_(
const PRMInstance< GUM_SCALAR >* i, NodeId n, InstanceMap& marks);
137 void _fromParent_(
const PRMInstance< GUM_SCALAR >* i, NodeId n, InstanceMap& marks);
140 void _fillMaps_(InstanceMap& marks);
143 std::string _buildHashKey_(
const PRMInstance< GUM_SCALAR >* i, Set< NodeId >& req_nodes);
146 const PRMInference< GUM_SCALAR >* _inf_;
152 HashTable<
const PRMInstance< GUM_SCALAR >*, std::pair< std::string, Set< NodeId >* > >
157 HashTable< std::string, std::pair< Set< NodeId >*, Size > > _reqMap_;
161 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 162 extern template class StructuredBayesBall<
double >;
169 # include <agrum/PRM/inference/structuredBayesBall_tpl.h>