11 #ifndef __BELIEF_PROPAGATION_H__
12 #define __BELIEF_PROPAGATION_H__
23 #ifdef HAVE_STD_UNORDERED_MAP
24 #include <unordered_map>
26 #include <tr1/unordered_map>
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 #define IGNORE_IN_CLASSLIST
53 GraphNode(int32_t
id, ENodeType type, int32_t pa)
54 : node_id(id), node_type(type), parent(pa) { }
64 MessageEdge(EEdgeType type, int32_t ch, int32_t pa)
65 : mtype(type), child(ch), parent(pa) { }
69 inline int32_t get_var_node()
71 return mtype == VAR_TO_FAC ? child : parent;
74 inline int32_t get_factor_node()
76 return mtype == VAR_TO_FAC ? parent : child;
85 CBeliefPropagation(CFactorGraph* fg);
87 virtual ~CBeliefPropagation();
90 virtual const char* get_name()
const {
return "BeliefPropagation"; }
92 virtual float64_t inference(SGVector<int32_t> assignment);
108 #ifdef HAVE_STD_UNORDERED_MAP
109 typedef std::unordered_map<uint32_t, uint32_t> msg_map_type;
110 typedef std::unordered_map<uint32_t, std::set<uint32_t> > msgset_map_type;
111 typedef std::unordered_multimap<int32_t, int32_t> var_factor_map_type;
113 typedef std::tr1::unordered_map<uint32_t, uint32_t> msg_map_type;
114 typedef std::tr1::unordered_map<uint32_t, std::set<uint32_t> > msgset_map_type;
115 typedef std::tr1::unordered_multimap<int32_t, int32_t> var_factor_map_type;
120 CTreeMaxProduct(CFactorGraph* fg);
122 virtual ~CTreeMaxProduct();
125 virtual const char* get_name()
const {
return "TreeMaxProduct"; }
127 virtual float64_t inference(SGVector<int32_t> assignment);
130 void bottom_up_pass();
131 void top_down_pass();
132 void get_message_order(std::vector<MessageEdge*>& order, std::vector<bool>& is_root)
const;
138 std::vector<MessageEdge*> m_msg_order;
139 std::vector<bool> m_is_root;
140 std::vector< std::vector<float64_t> > m_fw_msgs;
141 std::vector< std::vector<float64_t> > m_bw_msgs;
142 std::vector<int32_t> m_states;
144 msg_map_type m_msg_map_var;
145 msg_map_type m_msg_map_fac;
146 msgset_map_type m_msgset_map_var;
all of classes and functions are contained in the shogun namespace
#define IGNORE_IN_CLASSLIST