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
5 This file is part of libDAI.
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.
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.
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
24 #include <dai/alldai.h>
25 #include <dai/properties.h>
26 #include <dai/exceptions.h>
35 InfAlg
*newInfAlg( const std::string
&name
, const FactorGraph
&fg
, const PropertySet
&opts
) {
36 if( name
== ExactInf::Name
)
37 return new ExactInf (fg
, opts
);
39 if( name
== BP::Name
)
40 return new BP (fg
, opts
);
43 if( name
== MF::Name
)
44 return new MF (fg
, opts
);
47 if( name
== HAK::Name
)
48 return new HAK (fg
, opts
);
51 if( name
== LC::Name
)
52 return new LC (fg
, opts
);
54 #ifdef DAI_WITH_TREEEP
55 if( name
== TreeEP::Name
)
56 return new TreeEP (fg
, opts
);
59 if( name
== JTree::Name
)
60 return new JTree (fg
, opts
);
63 if( name
== MR::Name
)
64 return new MR (fg
, opts
);
67 if( name
== Gibbs::Name
)
68 return new Gibbs (fg
, opts
);
71 if( name
== CBP::Name
)
72 return new CBP (fg
, opts
);
74 DAI_THROWE(UNKNOWN_DAI_ALGORITHM
,"Unknown libDAI algorithm: " + name
);
78 /// \todo Make alias file non-testdai-specific, and use it in newInfAlgFromString
79 InfAlg
*newInfAlgFromString( const std::string
&nameOpts
, const FactorGraph
&fg
) {
80 string::size_type pos
= nameOpts
.find_first_of('[');
83 if( pos
== string::npos
) {
86 name
= nameOpts
.substr(0,pos
);
89 ss
<< nameOpts
.substr(pos
,nameOpts
.length());
92 return newInfAlg(name
,fg
,opts
);
96 } // end of namespace dai