-/* Copyright (C) 2006-2008 Joris Mooij [j dot mooij at science dot ru dot nl]
- Radboud University Nijmegen, The Netherlands
-
+/* Copyright (C) 2006-2008 Joris Mooij [joris dot mooij at tuebingen dot mpg dot de]
+ Radboud University Nijmegen, The Netherlands /
+ Max Planck Institute for Biological Cybernetics, Germany
+
This file is part of libDAI.
libDAI is free software; you can redistribute it and/or modify
using namespace std;
-InfAlg *newInfAlg( const string &name, const FactorGraph &fg, const PropertySet &opts ) {
+InfAlg *newInfAlg( const std::string &name, const FactorGraph &fg, const PropertySet &opts ) {
if( name == ExactInf::Name )
return new ExactInf (fg, opts);
-#ifdef WITH_BP
- if( name == BP::Name )
+#ifdef DAI_WITH_BP
+ if( name == BP::Name )
return new BP (fg, opts);
#endif
-#ifdef WITH_MF
- if( name == MF::Name )
+#ifdef DAI_WITH_MF
+ if( name == MF::Name )
return new MF (fg, opts);
#endif
-#ifdef WITH_HAK
- if( name == HAK::Name )
+#ifdef DAI_WITH_HAK
+ if( name == HAK::Name )
return new HAK (fg, opts);
#endif
-#ifdef WITH_LC
+#ifdef DAI_WITH_LC
if( name == LC::Name )
return new LC (fg, opts);
#endif
-#ifdef WITH_TREEEP
+#ifdef DAI_WITH_TREEEP
if( name == TreeEP::Name )
return new TreeEP (fg, opts);
#endif
-#ifdef WITH_JTREE
+#ifdef DAI_WITH_JTREE
if( name == JTree::Name )
return new JTree (fg, opts);
#endif
-#ifdef WITH_MR
+#ifdef DAI_WITH_MR
if( name == MR::Name )
return new MR (fg, opts);
#endif
- DAI_THROW(UNKNOWN_DAI_ALGORITHM);
+#ifdef DAI_WITH_GIBBS
+ if( name == Gibbs::Name )
+ return new Gibbs (fg, opts);
+#endif
+#ifdef DAI_WITH_CBP
+ if( name == CBP::Name )
+ return new CBP (fg, opts);
+#endif
+ DAI_THROWE(UNKNOWN_DAI_ALGORITHM,"Unknown libDAI algorithm: " + name);
+}
+
+
+/// \todo Make alias file non-testdai-specific, and use it in newInfAlgFromString
+InfAlg *newInfAlgFromString( const std::string &nameOpts, const FactorGraph &fg ) {
+ string::size_type pos = nameOpts.find_first_of('[');
+ string name;
+ PropertySet opts;
+ if( pos == string::npos ) {
+ name = nameOpts;
+ } else {
+ name = nameOpts.substr(0,pos);
+
+ stringstream ss;
+ ss << nameOpts.substr(pos,nameOpts.length());
+ ss >> opts;
+ }
+ return newInfAlg(name,fg,opts);
}