Multiple changes: changes in build system, one workaround and one bug fix
[libdai.git] / utils / fginfo.cpp
index efdd899..25c7a22 100644 (file)
@@ -95,13 +95,14 @@ int main( int argc, char *argv[] ) {
         cout << "Pairwise interactions? " << fg.isPairwise() << endl;
         
         // Calculate treewidth using various heuristics
-        std::pair<size_t,double> tw;
+#ifdef DAI_WITH_JTREE
+        std::pair<size_t,BigInt> tw;
         cout << "Treewidth (MinNeighbors):     ";
         try {
             tw = boundTreewidth(fg, &eliminationCost_MinNeighbors, maxstates );
             cout << tw.first << " (" << tw.second << " states)" << endl;
         } catch( Exception &e ) {
-            if( e.code() == Exception::OUT_OF_MEMORY )
+            if( e.getCode() == Exception::OUT_OF_MEMORY )
                 cout << "> " << maxstates << endl;
             else
                 cout << "an exception occurred" << endl;
@@ -112,7 +113,7 @@ int main( int argc, char *argv[] ) {
             tw = boundTreewidth(fg, &eliminationCost_MinWeight, maxstates );
             cout << tw.first << " (" << tw.second << " states)" << endl;
         } catch( Exception &e ) {
-            if( e.code() == Exception::OUT_OF_MEMORY )
+            if( e.getCode() == Exception::OUT_OF_MEMORY )
                 cout << "> " << maxstates << endl;
             else
                 cout << "an exception occurred" << endl;
@@ -123,7 +124,7 @@ int main( int argc, char *argv[] ) {
             tw = boundTreewidth(fg, &eliminationCost_MinFill, maxstates );
             cout << tw.first << " (" << tw.second << " states)" << endl;
         } catch( Exception &e ) {
-            if( e.code() == Exception::OUT_OF_MEMORY )
+            if( e.getCode() == Exception::OUT_OF_MEMORY )
                 cout << "> " << maxstates << endl;
             else
                 cout << "an exception occurred" << endl;
@@ -134,14 +135,15 @@ int main( int argc, char *argv[] ) {
             tw = boundTreewidth(fg, &eliminationCost_WeightedMinFill, maxstates );
             cout << tw.first << " (" << tw.second << " states)" << endl;
         } catch( Exception &e ) {
-            if( e.code() == Exception::OUT_OF_MEMORY )
+            if( e.getCode() == Exception::OUT_OF_MEMORY )
                 cout << "> " << maxstates << endl;
             else
                 cout << "an exception occurred" << endl;
         }
+#endif
         
         // Calculate total state space
-        long double stsp = 1.0;
+        BigInt stsp = 1;
         for( size_t i = 0; i < fg.nrVars(); i++ )
             stsp *= fg.var(i).states();
         cout << "Total state space:   " << stsp << endl;
@@ -149,9 +151,9 @@ int main( int argc, char *argv[] ) {
         cout << "Type: " << (fg.isPairwise() ? "pairwise" : "higher order") << " interactions, " << (fg.isBinary() ? "binary" : "nonbinary") << " variables" << endl;
 
         // Calculate complexity for LCBP
-        long double cavsum_lcbp = 0.0;
-        long double cavsum_lcbp2 = 0.0;
-        long double max_Delta_size = 0.0;
+        BigInt cavsum_lcbp = 0;
+        BigInt cavsum_lcbp2 = 0;
+        BigInt max_Delta_size = 0;
         map<size_t,size_t> cavsizes;
         for( size_t i = 0; i < fg.nrVars(); i++ ) {
             VarSet di = fg.delta(i);
@@ -159,7 +161,7 @@ int main( int argc, char *argv[] ) {
                 cavsizes[di.size()]++;
             else
                 cavsizes[di.size()] = 1;
-            long double Ds = fg.Delta(i).nrStates();
+            BigInt Ds = fg.Delta(i).nrStates();
             if( Ds > max_Delta_size )
                 max_Delta_size = Ds;
             cavsum_lcbp += di.nrStates();