00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00014
00015
00016 #ifndef __defined_libdai_fbp_h
00017 #define __defined_libdai_fbp_h
00018
00019
00020 #include <string>
00021 #include <dai/daialg.h>
00022 #include <dai/factorgraph.h>
00023 #include <dai/properties.h>
00024 #include <dai/enum.h>
00025 #include <dai/bp.h>
00026
00027
00028 namespace dai {
00029
00030
00032
00058 class FBP : public BP {
00059 protected:
00061 std::vector<Real> _weight;
00062
00063 public:
00065 static const char *Name;
00066
00067 public:
00069
00070
00071 FBP() : BP(), _weight() {}
00072
00074
00076 FBP( const FactorGraph &fg, const PropertySet &opts ) : BP(fg, opts), _weight() {
00077 setProperties( opts );
00078 construct();
00079 }
00081
00083
00084 virtual FBP* clone() const { return new FBP(*this); }
00085 virtual std::string identify() const;
00086 virtual Real logZ() const;
00088
00090
00091
00092 Real Weight( size_t I ) const { return _weight[I]; }
00093
00095 const std::vector<Real>& Weights() const { return _weight; }
00096
00098 void setWeight( size_t I, Real c ) { _weight[I] = c; }
00099
00101
00103 void setWeights( const std::vector<Real> &c ) { _weight = c; }
00104
00105 protected:
00107
00110 virtual Prob calcIncomingMessageProduct( size_t I, bool without_i, size_t i ) const;
00111
00112
00113 virtual void calcNewMessage( size_t i, size_t _I );
00114
00115
00116 virtual void calcBeliefF( size_t I, Prob &p ) const {
00117 p = calcIncomingMessageProduct( I, false, 0 );
00118 }
00119
00120
00121 virtual void construct();
00122 };
00123
00124
00125 }
00126
00127
00128 #endif