Removed all the virtual default constructors *::create(), as they are not used.
[libdai.git] / include / dai / exactinf.h
1 /* Copyright (C) 2006-2008 Joris Mooij [joris dot mooij at tuebingen dot mpg dot de]
2 Radboud University Nijmegen, The Netherlands /
3 Max Planck Institute for Biological Cybernetics, Germany
4
5 This file is part of libDAI.
6
7 libDAI is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 libDAI is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with libDAI; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22
23 /// \file
24 /// \brief Defines ExactInf class
25 /// \todo Improve documentation
26
27
28 #ifndef __defined_libdai_exactinf_h
29 #define __defined_libdai_exactinf_h
30
31
32 #include <dai/daialg.h>
33 #include <dai/properties.h>
34 #include <dai/factorgraph.h>
35 #include <dai/enum.h>
36
37
38 namespace dai {
39
40
41 /// Exact inference algorithm using brute force enumeration (mainly useful for testing purposes)
42 class ExactInf : public DAIAlgFG {
43 public:
44 /// Parameters of this inference algorithm
45 struct Properties {
46 /// Verbosity
47 size_t verbose;
48 } props;
49
50 /// Name of this inference algorithm
51 static const char *Name;
52
53 private:
54 std::vector<Factor> _beliefsV;
55 std::vector<Factor> _beliefsF;
56 Real _logZ;
57
58 public:
59 /// Default constructor
60 ExactInf() : DAIAlgFG(), props(), _beliefsV(), _beliefsF(), _logZ(0) {}
61
62 /// Construct from FactorGraph fg and PropertySet opts
63 ExactInf( const FactorGraph &fg, const PropertySet &opts ) : DAIAlgFG(fg), props(), _beliefsV(), _beliefsF(), _logZ() {
64 setProperties( opts );
65 construct();
66 }
67
68
69 /// @name General InfAlg interface
70 //@{
71 virtual ExactInf* clone() const { return new ExactInf(*this); }
72 virtual std::string identify() const;
73 virtual Factor belief( const Var &n ) const { return beliefV( findVar( n ) ); }
74 virtual Factor belief( const VarSet &ns ) const;
75 virtual std::vector<Factor> beliefs() const;
76 virtual Real logZ() const { return _logZ; }
77 virtual void init();
78 virtual void init( const VarSet &/*ns*/ ) { DAI_THROW(NOT_IMPLEMENTED); }
79 virtual double run();
80 virtual double maxDiff() const { DAI_THROW(NOT_IMPLEMENTED); return 0.0; }
81 virtual size_t Iterations() const { DAI_THROW(NOT_IMPLEMENTED); return 0; }
82 //@}
83
84
85 /// @name Additional interface specific for ExactInf
86 //@{
87 Factor beliefV( size_t i ) const { return _beliefsV[i]; }
88 Factor beliefF( size_t I ) const { return _beliefsF[I]; }
89 //@}
90
91 private:
92 void construct();
93 void setProperties( const PropertySet &opts );
94 PropertySet getProperties() const;
95 std::string printProperties() const;
96 };
97
98
99 } // end of namespace dai
100
101
102 #endif