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