00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00013
00014
00015 #ifndef __defined_libdai_trwbp_h
00016 #define __defined_libdai_trwbp_h
00017
00018
00019 #include <string>
00020 #include <dai/daialg.h>
00021 #include <dai/factorgraph.h>
00022 #include <dai/properties.h>
00023 #include <dai/enum.h>
00024 #include <dai/bp.h>
00025
00026
00027 namespace dai {
00028
00029
00031
00051 class TRWBP : public BP {
00052 protected:
00054
00059 std::vector<Real> _weight;
00060
00061 public:
00063 static const char *Name;
00064
00065 public:
00067
00068
00069 TRWBP() : BP(), _weight() {}
00070
00072
00074 TRWBP( const FactorGraph &fg, const PropertySet &opts ) : BP(fg, opts), _weight() {
00075 setProperties( opts );
00076 construct();
00077 }
00079
00081
00082 virtual TRWBP* clone() const { return new TRWBP(*this); }
00083 virtual std::string identify() const;
00084 virtual Real logZ() const;
00086
00088
00089
00090 Real Weight( size_t I ) const { return _weight[I]; }
00091
00093 const std::vector<Real>& Weights() const { return _weight; }
00094
00096 void setWeight( size_t I, Real c ) { _weight[I] = c; }
00097
00099
00101 void setWeights( const std::vector<Real> &c ) { _weight = c; }
00102
00103 protected:
00105
00108 virtual Prob calcIncomingMessageProduct( size_t I, bool without_i, size_t i ) const;
00109
00111 virtual void calcBeliefV( size_t i, Prob &p ) const;
00112
00113
00114 virtual void calcBeliefF( size_t I, Prob &p ) const {
00115 p = calcIncomingMessageProduct( I, false, 0 );
00116 }
00117
00118
00119 virtual void construct();
00120 };
00121
00122
00123 }
00124
00125
00126 #endif