Direct Graphical Models  v.1.7.0
GraphPairwiseKit.h
1 // Kit class for constructing the Dense Pairwise objects
2 // Written by Sergey Kosov in 2018 - 2019 for Project X
3 #pragma once
4 
5 #include "GraphKit.h"
6 
7 #include "GraphPairwise.h"
8 
9 #include "MessagePassing.h"
10 #include "InferLBP.h"
11 #include "InferTRW.h"
12 #include "InferViterbi.h"
13 
14 #include "GraphPairwiseExt.h"
15 
16 #include "macroses.h"
17 
18 namespace DirectGraphicalModels
19 {
21  enum class INFER {
22  LBP,
23  TRW,
24  Viterbi
25  };
26 
27  // ================================ Pairwise Graph Kit Class ===============================
33  class CGraphPairwiseKit : public CGraphKit {
34  public:
40  DllExport CGraphPairwiseKit(byte nStates, INFER infer = INFER::LBP)
41  : CGraphKit()
42  , m_graph(nStates)
44  {
45  switch (infer)
46  {
47  case INFER::LBP: m_pInfer = std::make_unique<CInferLBP>(m_graph); break;
48  case INFER::TRW: m_pInfer = std::make_unique<CInferTRW>(m_graph); break;
49  case INFER::Viterbi: m_pInfer = std::make_unique<CInferViterbi>(m_graph); break;
50  default: DGM_ASSERT_MSG(false, "Unknown inference method");
51  }
52  }
53  DllExport virtual ~CGraphPairwiseKit() = default;
54 
55  DllExport CGraph& getGraph() override { return m_graph; }
56  DllExport CInfer& getInfer() override { return *m_pInfer; }
57  DllExport CGraphExt& getGraphExt() override { return m_graphExtension; }
58 
59 
60  private:
62  std::unique_ptr<CMessagePassing> m_pInfer;
64  };
65 }
CGraphPairwise m_graph
Pairwise graph.
INFER
Types of the inference / decoding objects.
Abstract Kit class for constructing Graph-related objects.
Definition: GraphKit.h:27
Convergent Tree-Reweighted inference.
CGraphPairwiseKit(byte nStates, INFER infer=INFER::LBP)
Constructor.
CGraphPairwiseExt m_graphExtension
Pairwise graph extension.
Extended Pairwise graph class for 2D image classifaction.
CInfer & getInfer() override
Returns the inference / decoding object.
std::unique_ptr< CMessagePassing > m_pInfer
Inferer for pairwise graphs.
Interface class for graphical models.
Definition: Graph.h:14
General graph extension abstract class for 2D image classifaction.
Definition: GraphExt.h:16
CGraph & getGraph() override
Returns the graph object.
Base abstract class for random model inference.
Definition: Infer.h:19
Kit class for constructing Pairwise Graph objects.
CGraphExt & getGraphExt() override
Returns the graph extension object.
Loopy Belief Propagation inference.