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
00077 FBP( const FactorGraph &fg, const PropertySet &opts ) : BP(fg, opts), _weight() {
00078 setProperties( opts );
00079 construct();
00080 }
00082
00084
00085 virtual FBP* clone() const { return new FBP(*this); }
00086 virtual std::string identify() const;
00087 virtual Real logZ() const;
00089
00091
00092
00093 Real Weight( size_t I ) const { return _weight[I]; }
00094
00096 const std::vector<Real>& Weights() const { return _weight; }
00097
00099 void setWeight( size_t I, Real c ) { _weight[I] = c; }
00100
00102
00104 void setWeights( const std::vector<Real> &c ) { _weight = c; }
00105
00106 protected:
00108
00111 virtual Prob calcIncomingMessageProduct( size_t I, bool without_i, size_t i ) const;
00112
00113
00114 virtual void calcNewMessage( size_t i, size_t _I );
00115
00116
00117 virtual void calcBeliefF( size_t I, Prob &p ) const {
00118 p = calcIncomingMessageProduct( I, false, 0 );
00119 }
00120
00121
00122 virtual void construct();
00123 };
00124
00125
00126 }
00127
00128
00129 #endif