libDAI
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
include
dai
fbp.h
Go to the documentation of this file.
1
/* This file is part of libDAI - http://www.libdai.org/
2
*
3
* Copyright (c) 2006-2011, The libDAI authors. All rights reserved.
4
*
5
* Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
6
*/
7
8
11
12
13
#ifndef __defined_libdai_fbp_h
14
#define __defined_libdai_fbp_h
15
16
17
#include <string>
18
#include <
dai/daialg.h
>
19
#include <
dai/factorgraph.h
>
20
#include <
dai/properties.h
>
21
#include <
dai/enum.h
>
22
#include <
dai/bp.h
>
23
24
25
namespace
dai {
26
27
29
55
class
FBP
:
public
BP
{
56
protected
:
58
std::vector<Real>
_weight
;
59
60
public
:
62
63
64
FBP
() :
BP
(),
_weight
() {}
65
67
70
FBP
(
const
FactorGraph
&
fg
,
const
PropertySet
&opts ) :
BP
(fg, opts),
_weight
() {
71
setProperties
( opts );
72
construct
();
73
}
75
77
78
virtual
FBP
*
clone
()
const
{
return
new
FBP
(*
this
); }
79
virtual
FBP
*
construct
(
const
FactorGraph
&
fg
,
const
PropertySet
&opts )
const
{
return
new
FBP
( fg, opts ); }
80
virtual
std::string
name
()
const
{
return
"FBP"
; }
81
virtual
Real
logZ
()
const
;
83
85
86
87
Real
Weight
(
size_t
I )
const
{
return
_weight
[I]; }
88
90
const
std::vector<Real>&
Weights
()
const
{
return
_weight
; }
91
93
void
setWeight
(
size_t
I,
Real
c ) {
_weight
[I] = c; }
94
96
98
void
setWeights
(
const
std::vector<Real> &c ) {
_weight
= c; }
99
100
protected
:
102
105
virtual
Prob
calcIncomingMessageProduct
(
size_t
I,
bool
without_i,
size_t
i )
const
;
106
107
// Calculate the updated message from the \a _I 'th neighbor of variable \a i to variable \a i
108
virtual
void
calcNewMessage
(
size_t
i,
size_t
_I );
109
110
// Calculates unnormalized belief of factor \a I
111
virtual
void
calcBeliefF
(
size_t
I,
Prob
&p )
const
{
112
p =
calcIncomingMessageProduct
( I,
false
, 0 );
113
}
114
115
// Helper function for constructors
116
virtual
void
construct
();
117
};
118
119
120
}
// end of namespace dai
121
122
123
#endif
Generated on Mon Sep 17 2012 12:30:34 for libDAI by
1.8.1.2