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 DAI_WITH_BP
- if( name == BP::Name )
+ if( name == BP::Name )
return new BP (fg, opts);
#endif
#ifdef DAI_WITH_MF
- if( name == MF::Name )
+ if( name == MF::Name )
return new MF (fg, opts);
#endif
#ifdef DAI_WITH_HAK
- if( name == HAK::Name )
+ if( name == HAK::Name )
return new HAK (fg, opts);
#endif
#ifdef DAI_WITH_LC
if( name == Gibbs::Name )
return new Gibbs (fg, opts);
#endif
- DAI_THROW(UNKNOWN_DAI_ALGORITHM);
+#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);
}