OpenGM  2.3.x
Discrete Graphical Model Library
cgc/visitors.hxx
Go to the documentation of this file.
1 #ifndef OPENGM_CGC_VISITORS
2 #define OPENGM_CGC_VISITORS
3 
4 #include <opengm/opengm.hxx>
5 
6 template<class CGC>
8 public:
9  typedef CGC InfType;
10  typedef typename InfType::AccumulationType AccumulationType;
11  typedef typename InfType::GraphicalModelType GraphicalModelType;
13 
15  const GraphicalModelType & gm,
16  std::list< std::vector<typename GraphicalModelType::LabelType> >& l,
17  const size_t visitNth=10,const size_t skipN=10
18  )
19  : gm_(gm),
20  visitNth_(visitNth),
21  visitNr_(0),
22  skipN_(skipN),
23  l_(l)
24  {
25  OPENGM_CHECK_OP(visitNth,>=,1," ");
26 
27  }
28 
29  void begin(InfType & inf ,const ValueType val,const ValueType bound){
30 
31  }
32  void end(InfType & inf ,const ValueType val,const ValueType bound){
33 
34  }
35 
36  void operator()(InfType & inf ,const ValueType val,const ValueType bound){
37  const bool inRecursive2Coloring = inf.inRecursive2Coloring();
38  const bool inGreedy2Coloring = inf.inRecursive2Coloring();
39  if(visitNr_>=skipN_ && ( (visitNr_-skipN_)==0 || (visitNr_-skipN_) % visitNth_==0) ){
40  // get arg
41  inf.arg(argBuffer_);
42  l_.push_back(argBuffer_);
43  }
44  else {
45  throw std::runtime_error("no!");
46  }
47  ++visitNr_;
48  }
49 
50 
51 private:
52  GraphicalModelType gm_;
53  size_t visitNth_;
54  size_t visitNr_;
55  size_t skipN_;
56 
57  std::vector<LabelType> argBuffer_;
58  std::list< std::vector<LabelType> >& l_;
59 };
60 
61 
62 #endif // OPENGM_CGC_VISITORS
InfType::AccumulationType AccumulationType
void operator()(InfType &inf, const ValueType val, const ValueType bound)
CgcStateVisitor(const GraphicalModelType &gm, std::list< std::vector< typename GraphicalModelType::LabelType > > &l, const size_t visitNth=10, const size_t skipN=10)
void end(InfType &inf, const ValueType val, const ValueType bound)
void begin(InfType &inf, const ValueType val, const ValueType bound)
#define OPENGM_CHECK_OP(A, OP, B, TXT)
Definition: submodel2.hxx:24
InfType::GraphicalModelType GraphicalModelType