Moved platform independent build options into Makefile.ALL and documented tests/testdai
[libdai.git] / include / dai / alldai.h
1 /* This file is part of libDAI - http://www.libdai.org/
2 *
3 * libDAI is licensed under the terms of the GNU General Public License version
4 * 2, or (at your option) any later version. libDAI is distributed without any
5 * warranty. See the file COPYING for more details.
6 *
7 * Copyright (C) 2006-2010 Joris Mooij [joris dot mooij at libdai dot org]
8 * Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
9 */
10
11
12 /// \file
13 /// \brief Main libDAI header file. It \#includes all other libDAI headers.
14
15
16 #ifndef __defined_libdai_alldai_h
17 #define __defined_libdai_alldai_h
18
19
20 #include <string>
21 #include <dai/daialg.h>
22 #include <dai/properties.h>
23 #include <dai/exactinf.h>
24 #include <dai/evidence.h>
25 #include <dai/emalg.h>
26 #ifdef DAI_WITH_BP
27 #include <dai/bp.h>
28 #endif
29 #ifdef DAI_WITH_FBP
30 #include <dai/fbp.h>
31 #endif
32 #ifdef DAI_WITH_TRWBP
33 #include <dai/trwbp.h>
34 #endif
35 #ifdef DAI_WITH_MF
36 #include <dai/mf.h>
37 #endif
38 #ifdef DAI_WITH_HAK
39 #include <dai/hak.h>
40 #endif
41 #ifdef DAI_WITH_LC
42 #include <dai/lc.h>
43 #endif
44 #ifdef DAI_WITH_TREEEP
45 #include <dai/treeep.h>
46 #endif
47 #ifdef DAI_WITH_JTREE
48 #include <dai/jtree.h>
49 #endif
50 #ifdef DAI_WITH_MR
51 #include <dai/mr.h>
52 #endif
53 #ifdef DAI_WITH_GIBBS
54 #include <dai/gibbs.h>
55 #endif
56 #ifdef DAI_WITH_CBP
57 #include <dai/cbp.h>
58 #endif
59
60
61 /// Namespace for libDAI
62 namespace dai {
63
64
65 /// Constructs a new inference algorithm.
66 /** \param name The name of the inference algorithm (should be one of the names in DAINames).
67 * \param fg The FactorGraph that the algorithm should be applied to.
68 * \param opts A PropertySet specifying the options for the algorithm.
69 * \return Returns a pointer to the new InfAlg object; it is the responsibility of the caller to delete it later.
70 * \throw UNKNOWN_DAI_ALGORITHM if the requested name is not known/compiled in.
71 */
72 InfAlg *newInfAlg( const std::string &name, const FactorGraph &fg, const PropertySet &opts );
73
74
75 /// Constructs a new inference algorithm.
76 /** \param nameOpts The name and options of the inference algorithm (should be in the format "name[key1=val1,key2=val2,...,keyn=valn]").
77 * \param fg The FactorGraph that the algorithm should be applied to.
78 * \return Returns a pointer to the new InfAlg object; it is the responsibility of the caller to delete it later.
79 * \throw UNKNOWN_DAI_ALGORITHM if the requested name is not known/compiled in.
80 */
81 InfAlg *newInfAlgFromString( const std::string &nameOpts, const FactorGraph &fg );
82
83
84 /// Constructs a new inference algorithm.
85 /** \param aliases Maps names to strings in the format "name[key1=val1,key2=val2,...,keyn=valn]"; if not empty, alias substitution
86 * will be performed when parsing \a nameOpts by invoking parseNameProperties(const std::string &,const std::map<std::string,std::string> &)
87 * \see newInfAlgFromString(const std::string &, const FactorGraph &)
88 */
89 InfAlg *newInfAlgFromString( const std::string &nameOpts, const FactorGraph &fg, const std::map<std::string,std::string> &aliases );
90
91
92 /// Extracts the name and property set from a string \a s in the format "name[key1=val1,key2=val2,...]" or "name"
93 std::pair<std::string, PropertySet> parseNameProperties( const std::string &s );
94
95
96 /// Extracts the name and property set from a string \a s in the format "name[key1=val1,key2=val2,...]" or "name", performing alias substitution
97 /** Alias substitution is performed as follows: as long as name appears as a key in \a aliases,
98 * it is substituted by its value. Properties in \a s override those of the alias (in case of
99 * recursion, the "outer" properties override those of the "inner" aliases).
100 */
101 std::pair<std::string, PropertySet> parseNameProperties( const std::string &s, const std::map<std::string,std::string> &aliases );
102
103
104 /// Reads aliases from file named \a filename
105 /** \param filename Name of the alias file
106 * \return A map that maps aliases to the strings they should be substituted with.
107 * \see \ref fileformats-aliases
108 */
109 std::map<std::string,std::string> readAliasesFile( const std::string &filename );
110
111
112 /// Contains the names of all inference algorithms compiled into libDAI.
113 static const char* DAINames[] = {
114 ExactInf::Name,
115 #ifdef DAI_WITH_BP
116 BP::Name,
117 #endif
118 #ifdef DAI_WITH_FBP
119 FBP::Name,
120 #endif
121 #ifdef DAI_WITH_TRWBP
122 TRWBP::Name,
123 #endif
124 #ifdef DAI_WITH_MF
125 MF::Name,
126 #endif
127 #ifdef DAI_WITH_HAK
128 HAK::Name,
129 #endif
130 #ifdef DAI_WITH_LC
131 LC::Name,
132 #endif
133 #ifdef DAI_WITH_TREEEP
134 TreeEP::Name,
135 #endif
136 #ifdef DAI_WITH_JTREE
137 JTree::Name,
138 #endif
139 #ifdef DAI_WITH_MR
140 MR::Name,
141 #endif
142 #ifdef DAI_WITH_GIBBS
143 Gibbs::Name,
144 #endif
145 #ifdef DAI_WITH_CBP
146 CBP::Name,
147 #endif
148 ""
149 };
150
151
152 } // end of namespace dai
153
154
155 #endif