git master
----------
+* Fixed bug in findMaximum (it only considered a single connected component of the factor graph)
* [Benjamin Piwowarski] Renamed "foreach" macro into "bforeach" to avoid conflicts with newer Boost library versions
* Optimized ClusterGraph( const FactorGraph&, bool) constructor
* Fixed "typename" bug in src/alldai.cpp which resulted in FTBFS for older g++ compilers
vector<bool> visitedVars( obj.fg().nrVars(), false );
vector<bool> visitedFactors( obj.fg().nrFactors(), false );
stack<size_t> scheduledFactors;
- scheduledFactors.push( 0 );
- while( !scheduledFactors.empty() ) {
+ size_t nrVisitedFactors = 0;
+ size_t firstUnvisitedFactor = 0;
+ while( nrVisitedFactors < obj.fg().nrFactors() ) {
+ if( scheduledFactors.size() == 0 ) {
+ while( visitedFactors[firstUnvisitedFactor] ) {
+ firstUnvisitedFactor++;
+ if( firstUnvisitedFactor >= obj.fg().nrFactors() )
+ DAI_THROWE(RUNTIME_ERROR,"Internal error in findMaximum()");
+ }
+ scheduledFactors.push( firstUnvisitedFactor );
+ }
+
size_t I = scheduledFactors.top();
scheduledFactors.pop();
if( visitedFactors[I] )
continue;
visitedFactors[I] = true;
+ nrVisitedFactors++;
// Get marginal of factor I
Prob probF = obj.beliefF(I).p();