/usr/include/opengm/inference/external/libdai/tree_reweighted_bp.hxx is in libopengm-dev 2.3.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #ifndef OPENGM_LIBDAI_TRBP_HXX
#define OPENGM_LIBDAI_TRBP_HXX
#include "opengm/inference/external/libdai/inference.hxx"
namespace opengm{
namespace external{
namespace libdai{
/// \brief tree reweighted belief propagation : \n
/// [?]
///
/// \ingroup inference
/// \ingroup messagepassing_inference
/// \ingroup external_inference
/// Tree Reweighted Belief Propagation :
/// - cite :[?]
/// - Maximum factor order :\f$\infty\f$
/// - Maximum number of labels : \f$\infty\f$
/// - Restrictions : ?
/// - Convergent : convergent on trees
template<class GM,class ACC>
class TreeReweightedBp : public LibDaiInference<GM,ACC,TreeReweightedBp<GM,ACC> >
, public opengm::Inference<GM,ACC>{
public:
typedef ACC AccumulationType;
typedef GM GraphicalModelType;
OPENGM_GM_TYPE_TYPEDEFS;
typedef opengm::visitors::VerboseVisitor< TreeReweightedBp<GM,ACC> > VerboseVisitorType;
typedef opengm::visitors::TimingVisitor< TreeReweightedBp<GM,ACC> > TimingVisitorType;
typedef opengm::visitors::EmptyVisitor< TreeReweightedBp<GM,ACC> > EmptyVisitorType;
enum UpdateRule{
PARALL,
SEQFIX,
SEQRND,
SEQMAX
};
std::string name() const {
return "libDAI-Tree-Reweighted-Bp";
}
struct Parameter{
Parameter
(
const size_t maxIterations=100,
const double damping=0.0,
const double tolerance=0.000001,
const size_t ntrees=0,
UpdateRule updateRule= PARALL,
const size_t verbose=0
) :maxIterations_(maxIterations),
damping_(damping),
tolerance_(tolerance),
ntrees_(ntrees),
updateRule_(updateRule),
verbose_(verbose),
logDomain_(0) {
}
std::string toString( )const{
std::string ur;
std::stringstream ss;
if(updateRule_==PARALL)ur="PARALL";
else if(updateRule_==SEQFIX)ur = "SEQFIX";
else if(updateRule_==SEQMAX)ur = "SEQMAX";
else if(updateRule_==SEQRND)ur = "SEQRND";
ss <<"TRWBP["
<<"updates="<<ur<<","
<<"damping="<<damping_<<","
<<"maxiter="<<maxIterations_<<","
<<"tol="<<tolerance_<<","
<<"ntrees="<<ntrees_<<","
<<"logdomain="<<logDomain_<<","
<<"inference="<< std::string(::opengm::meta::Compare<ACC,::opengm::Integrator>::value==true ? std::string("SUMPROD") : std::string("MAXPROD") ) <<","
<<"verbose="<<verbose_<<"]";
return ss.str();
}
size_t maxIterations_;
double damping_;
double tolerance_;
UpdateRule updateRule_;
size_t ntrees_;
size_t verbose_;
size_t logDomain_;
};
TreeReweightedBp(const GM & gm,const Parameter param=Parameter())
:LibDaiInference<GM,ACC,TreeReweightedBp<GM,ACC> >(gm,param.toString()) {
}
virtual const GraphicalModelType& graphicalModel() const{
return this->graphicalModel_impl();
}
virtual void reset(){
return this->reset_impl();
}
virtual InferenceTermination infer(){
return this->infer_impl();
}
template<class VISITOR>
InferenceTermination infer(VISITOR& visitor ){
visitor.begin(*this);
InferenceTermination infTerm = this->infer_impl();
visitor.end(*this);
return infTerm;
}
virtual InferenceTermination arg(std::vector<LabelType>& v, const size_t argnr=1)const{
return this->arg_impl(v,argnr);
}
virtual InferenceTermination marginal(const size_t v, IndependentFactorType& m) const{
return this->marginal_impl(v,m);
}
virtual InferenceTermination factorMarginal(const size_t f, IndependentFactorType& m) const{
return this->factorMarginal_impl(f,m);
}
};
} // end namespace libdai
} // end namespace external
} //end namespace opengm
#endif // OPENGM_LIBDAI_TRBP_HXX
|