1 /* This file is part of libDAI - http://www.libdai.org/
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.
7 * Copyright (C) 2006-2010 Joris Mooij [joris dot mooij at libdai dot org]
8 * Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
13 /// \brief Main libDAI header file. It \#includes all other libDAI headers.
16 #ifndef __defined_libdai_alldai_h
17 #define __defined_libdai_alldai_h
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>
33 #include <dai/trwbp.h>
44 #ifdef DAI_WITH_TREEEP
45 #include <dai/treeep.h>
48 #include <dai/jtree.h>
54 #include <dai/gibbs.h>
61 /// Namespace for libDAI
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.
72 InfAlg
*newInfAlg( const std::string
&name
, const FactorGraph
&fg
, const PropertySet
&opts
);
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.
81 InfAlg
*newInfAlgFromString( const std::string
&nameOpts
, const FactorGraph
&fg
);
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 &)
89 InfAlg
*newInfAlgFromString( const std::string
&nameOpts
, const FactorGraph
&fg
, const std::map
<std::string
,std::string
> &aliases
);
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
);
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).
101 std::pair
<std::string
, PropertySet
> parseNameProperties( const std::string
&s
, const std::map
<std::string
,std::string
> &aliases
);
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
109 std::map
<std::string
,std::string
> readAliasesFile( const std::string
&filename
);
112 /// Contains the names of all inference algorithms compiled into libDAI.
113 static const char* DAINames
[] = {
121 #ifdef DAI_WITH_TRWBP
133 #ifdef DAI_WITH_TREEEP
136 #ifdef DAI_WITH_JTREE
142 #ifdef DAI_WITH_GIBBS
152 } // end of namespace dai