+* Fixed numerical issues in MF, FBP and TRWBP (discovered in sparse branch)
* Jerome Maye found a bug in the State() class in index.h; implemented
a workaround for the moment
* Fixed bug in findMaximum(): inconsistent max-beliefs are now detected,
Real c_i = 0.0;
foreach( const Neighbor &I, nbV(i) )
c_i += Weight(I);
- sum += (1.0 - c_i) * beliefV(i).entropy(); // FBP
+ if( c_i != 1.0 )
+ sum += (1.0 - c_i) * beliefV(i).entropy(); // FBP
}
return sum;
}
prod_j += message( j, J.iter );
else
prod_j *= message( j, J.iter );
- } else {
+ } else if( c_I != 1.0 ) {
// FBP: multiply by m_Ij^(1-1/c_I)
if( props.logdomain )
prod_j += newMessage( j, J.iter) * (1.0 - 1.0 / c_I);
belief_I_minus_i *= _beliefs[j];
Factor f_I = factor(I);
if( props.updates == Properties::UpdateType::NAIVE )
- f_I.takeLog();
+ f_I.takeLog(true);
Factor msg_I_i = (belief_I_minus_i * f_I).marginal( var(i), false );
if( props.updates == Properties::UpdateType::NAIVE )
result *= msg_I_i.exp();
Real c_i = 0.0;
foreach( const Neighbor &I, nbV(i) )
c_i += Weight(I);
- sum += (1.0 - c_i) * beliefV(i).entropy(); // TRWBP/FBP
+ if( c_i != 1.0 )
+ sum += (1.0 - c_i) * beliefV(i).entropy(); // TRWBP/FBP
}
return sum;
}
prod_j += message( j, J.iter ) * c_J;
else
prod_j *= message( j, J.iter ) ^ c_J;
- } else { // TRWBP: multiply by m_Ij^(c_I-1)
+ } else if( c_J != 1.0 ) { // TRWBP: multiply by m_Ij^(c_I-1)
if( props.logdomain )
prod_j += message( j, J.iter ) * (c_J - 1.0);
else