OpenGM  2.3.x
Discrete Graphical Model Library
exact.hxx
Go to the documentation of this file.
1 #ifndef OPENGM_LIBDAI_EXACT_HXX
2 #define OPENGM_LIBDAI_EXACT_HXX
3 
5 
7 
8 namespace opengm{
9 namespace external{
10 namespace libdai{
11 
12 template<class GM,class ACC>
13 class Exact : public opengm::external::libdai::LibDaiInference<GM,ACC,Exact<GM,ACC> >, public opengm::Inference<GM,ACC>{
14  public:
15  typedef ACC AccumulationType;
16  typedef GM GraphicalModelType;
18  typedef opengm::visitors::VerboseVisitor< Exact<GM,ACC> > VerboseVisitorType;
19  typedef opengm::visitors::TimingVisitor< Exact<GM,ACC> > TimingVisitorType;
20  typedef opengm::visitors::EmptyVisitor< Exact<GM,ACC> > EmptyVisitorType;
21 
22  enum UpdateRule{
23  PARALL,
24  SEQFIX,
25  SEQRND,
26  SEQMAX
27  };
28  std::string name() const{
29  return "libDAI-Exact";
30  }
31  struct Parameter{
32  Parameter
33  (
34  const size_t verbose=0
35  ) :
36  verbose_(verbose),
37  logDomain_(0) {
38 
39  }
40  std::string toString()const{
41  std::stringstream ss;
42  ss <<"EXACT["
43  <<"logdomain="<<logDomain_<<","
44  <<"verbose="<<verbose_<<"]";
45  return ss.str();
46  }
47  size_t logDomain_;
48  size_t verbose_;
49  };
50  Exact(const GM & gm,const Parameter param=Parameter())
51  :LibDaiInference<GM,ACC,Exact<GM,ACC> >(gm,param.toString()) {
52 
53  }
54 
55  virtual const GraphicalModelType& graphicalModel() const{
56  return this->graphicalModel_impl();
57  }
58 
59  virtual void reset(){
60  return this->reset_impl();
61  }
62 
63  virtual InferenceTermination infer(){
64  return this->infer_impl();
65  }
66 
67  template<class VISITOR>
68  InferenceTermination infer(VISITOR& visitor ){
69  visitor.begin(*this);
70  InferenceTermination infTerm = this->infer_impl();
71  visitor.end(*this);
72  return infTerm;
73  }
74 
75  virtual InferenceTermination arg(std::vector<LabelType>& v, const size_t argnr=1)const{
76  return this->arg_impl(v,argnr);
77  }
78  virtual InferenceTermination marginal(const size_t v, IndependentFactorType& m) const{
79  return this->marginal_impl(v,m);
80  }
81  virtual InferenceTermination factorMarginal(const size_t f, IndependentFactorType& m) const{
82  return this->factorMarginal_impl(f,m);
83  }
84 };
85 
86 } // end namespace libdai
87 } // end namespace external
88 } //end namespace opengm
89 
91 
92 #endif // OPENGM_LIBDAI_EXACT_HXX
The OpenGM namespace.
Definition: config.hxx:43
Inference algorithm interface.
Definition: inference.hxx:34
#define OPENGM_GM_TYPE_TYPEDEFS
Definition: inference.hxx:13
InferenceTermination
Definition: inference.hxx:24