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-2009 Joris Mooij [joris dot mooij at libdai dot org]
8 * Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
13 #include <dai/alldai.h>
14 #include <dai/properties.h>
15 #include <dai/exceptions.h>
24 InfAlg
*newInfAlg( const std::string
&name
, const FactorGraph
&fg
, const PropertySet
&opts
) {
25 if( name
== ExactInf::Name
)
26 return new ExactInf (fg
, opts
);
28 if( name
== BP::Name
)
29 return new BP (fg
, opts
);
32 if( name
== MF::Name
)
33 return new MF (fg
, opts
);
36 if( name
== HAK::Name
)
37 return new HAK (fg
, opts
);
40 if( name
== LC::Name
)
41 return new LC (fg
, opts
);
43 #ifdef DAI_WITH_TREEEP
44 if( name
== TreeEP::Name
)
45 return new TreeEP (fg
, opts
);
48 if( name
== JTree::Name
)
49 return new JTree (fg
, opts
);
52 if( name
== MR::Name
)
53 return new MR (fg
, opts
);
56 if( name
== Gibbs::Name
)
57 return new Gibbs (fg
, opts
);
60 if( name
== CBP::Name
)
61 return new CBP (fg
, opts
);
63 DAI_THROWE(UNKNOWN_DAI_ALGORITHM
,"Unknown libDAI algorithm: " + name
);
67 /// \todo Make alias file non-testdai-specific, and use it in newInfAlgFromString
68 InfAlg
*newInfAlgFromString( const std::string
&nameOpts
, const FactorGraph
&fg
) {
69 string::size_type pos
= nameOpts
.find_first_of('[');
72 if( pos
== string::npos
) {
75 name
= nameOpts
.substr(0,pos
);
78 ss
<< nameOpts
.substr(pos
,nameOpts
.length());
81 return newInfAlg(name
,fg
,opts
);
85 } // end of namespace dai