/// \file
/// \brief Defines class BBP [\ref EaG09]
/// \todo Improve documentation
-/// \todo Debug clean_updates
#ifndef ___defined_libdai_bbp_h
//@{
/// Helper function for sendSeqMsgM: increases factor->variable message adjoint by p and calculates the corresponding unnormalized adjoint
void incrSeqMsgM( size_t i, size_t _I, const Prob& p );
- void updateSeqMsgM( size_t i, size_t _I );
+ // DISABLED BECAUSE IT IS BUGGY:
+ // void updateSeqMsgM( size_t i, size_t _I );
/// Sets normalized factor->variable message adjoint and calculates the corresponding unnormalized adjoint
void setSeqMsgM( size_t i, size_t _I, const Prob &p );
/// Implements routine Send-n in Figure 5 in [\ref EaG09]
/// Update schedule
UpdateType updates;
- bool clean_updates;
+ // DISABLED BECAUSE IT IS BUGGY:
+ // bool clean_updates;
}
*/
/* {{{ GENERATED CODE: DO NOT EDIT. Created by
double damping;
/// Update schedule
UpdateType updates;
- bool clean_updates;
/// Set members from PropertySet
void set(const PropertySet &opts);
void BBP::incrSeqMsgM( size_t i, size_t _I, const Prob &p ) {
- if( props.clean_updates )
+/* if( props.clean_updates )
_new_adj_m[i][_I] += p;
- else {
+ else {*/
_adj_m[i][_I] += p;
calcUnnormMsgM(i, _I);
- }
+// }
}
#endif
+/*
void BBP::updateSeqMsgM( size_t i, size_t _I ) {
if( props.clean_updates ) {
#if 0
_new_adj_m[i][_I].fill( 0.0 );
}
}
-
+*/
void BBP::setSeqMsgM( size_t i, size_t _I, const Prob &p ) {
_adj_m[i][_I] = p;
for( size_t i = 0; i < _fg->nrVars(); i++ )
foreach( const Neighbor &I, _fg->nbV(i) )
sendSeqMsgM( i, I.iter );
- for( size_t i = 0; i < _fg->nrVars(); i++ )
+/* for( size_t i = 0; i < _fg->nrVars(); i++ )
foreach( const Neighbor &I, _fg->nbV(i) )
- updateSeqMsgM( i, I.iter );
+ updateSeqMsgM( i, I.iter );*/
} while( mag > tol && _iters < props.maxiter );
if( _iters >= props.maxiter )
if(*i == "tol") continue;
if(*i == "damping") continue;
if(*i == "updates") continue;
- if(*i == "clean_updates") continue;
cerr << "BBP: Unknown property " << *i << endl;
die=true;
}
cerr << "BBP: Missing property \"updates\" for method \"BBP\"" << endl;
die=true;
}
- if(!opts.hasKey("clean_updates")) {
- cerr << "BBP: Missing property \"clean_updates\" for method \"BBP\"" << endl;
- die=true;
- }
if(die) {
DAI_THROW(NOT_ALL_PROPERTIES_SPECIFIED);
}
tol = opts.getStringAs<double>("tol");
damping = opts.getStringAs<double>("damping");
updates = opts.getStringAs<UpdateType>("updates");
- clean_updates = opts.getStringAs<bool>("clean_updates");
}
PropertySet BBP::Properties::get() const {
PropertySet opts;
opts.Set("tol", tol);
opts.Set("damping", damping);
opts.Set("updates", updates);
- opts.Set("clean_updates", clean_updates);
return opts;
}
string BBP::Properties::toString() const {
s << "tol=" << tol << ",";
s << "damping=" << damping << ",";
s << "updates=" << updates << ",";
- s << "clean_updates=" << clean_updates;
s << "]";
return s.str();
}
# --- CBP ---------------------
-CBP: CBP[max_levels=12,updates=SEQMAX,tol=1e-9,rec_tol=1e-9,maxiter=500,choose=CHOOSE_RANDOM,recursion=REC_FIXED,clamp=CLAMP_VAR,min_max_adj=1.0e-9,bbp_cfn=CFN_FACTOR_ENT,verbose=0,rand_seed=0,bbp_props=[verbose=0,tol=1.0e-9,maxiter=10000,damping=0,updates=SEQ_BP_REV,clean_updates=0],clamp_outfile=]
+CBP: CBP[max_levels=12,updates=SEQMAX,tol=1e-9,rec_tol=1e-9,maxiter=500,choose=CHOOSE_RANDOM,recursion=REC_FIXED,clamp=CLAMP_VAR,min_max_adj=1.0e-9,bbp_cfn=CFN_FACTOR_ENT,verbose=0,rand_seed=0,bbp_props=[verbose=0,tol=1.0e-9,maxiter=10000,damping=0,updates=SEQ_BP_REV],clamp_outfile=]
BBP: CBP[choose=CHOOSE_BBP]
size_t maxiter = 10000;
double damping = 0.0;
BBP::Properties::UpdateType updates = BBP::Properties::UpdateType::PAR;
- bool clean_updates = false;
// Store the constants in a PropertySet object
PropertySet opts;
vector<size_t> state( fg.nrVars(), 0 );
- for( size_t t = 0; t < 90; t++ ) {
- clean_updates = t % 2;
+ for( size_t t = 0; t < 45; t++ ) {
BBP::Properties::UpdateType updates;
- switch( (t / 2) % 5 ) {
+ switch( t % 5 ) {
case BBP::Properties::UpdateType::SEQ_FIX:
updates = BBP::Properties::UpdateType::SEQ_FIX;
break;
break;
}
bbp_cfn_t cfn;
- switch( (t / 10) % 9 ) {
+ switch( (t / 5) % 9 ) {
case 0:
cfn = bbp_cfn_t::CFN_GIBBS_B;
break;
}
double h = 1e-4;
- double result = numericBBPTest( bp, &state, opts("updates",updates)("clean_updates",clean_updates), cfn, h );
- cout << "clean_updates=" << clean_updates << ", updates=" << updates << ", cfn=" << cfn << ", result: " << result << endl;
+ double result = numericBBPTest( bp, &state, opts("updates",updates), cfn, h );
+ cout << "result: " << result << ",\tupdates=" << updates << ", cfn=" << cfn << endl;
}
}