Finished a new release: libDAI v0.2.6
[libdai.git] / tests / testbbp.cpp
index 9a4a8b9..5747d84 100644 (file)
@@ -30,17 +30,17 @@ int main( int argc, char *argv[] ) {
 
         // Set some constants
         size_t verbose = 0;
-        double tol = 1.0e-9;
+        Real   tol = 1.0e-9;
         size_t maxiter = 10000;
-        double damping = 0.0;
+        Real   damping = 0.0;
         BBP::Properties::UpdateType updates = BBP::Properties::UpdateType::PAR;
 
         // Store the constants in a PropertySet object
         PropertySet opts;
-        opts.Set("verbose",verbose);  // Verbosity (amount of output generated)
-        opts.Set("tol",tol);          // Tolerance for convergence
-        opts.Set("maxiter",maxiter);  // Maximum number of iterations
-        opts.Set("damping",damping);  // Amount of damping applied
+        opts.set("verbose",verbose);  // Verbosity (amount of output generated)
+        opts.set("tol",tol);          // Tolerance for convergence
+        opts.set("maxiter",maxiter);  // Maximum number of iterations
+        opts.set("damping",damping);  // Amount of damping applied
 
         // Construct a BP (belief propagation) object from the FactorGraph fg
         BP bp(fg, opts("updates",string("SEQFIX"))("logdomain",false));
@@ -69,39 +69,39 @@ int main( int argc, char *argv[] ) {
                     updates = BBP::Properties::UpdateType::PAR;
                     break;
             }
-            bbp_cfn_t cfn;
+            BBPCostFunction cfn;
             switch( (t / 5) % 9 ) {
                 case 0:
-                    cfn = bbp_cfn_t::CFN_GIBBS_B;
+                    cfn = BBPCostFunction::CFN_GIBBS_B;
                     break;
                 case 1:
-                    cfn = bbp_cfn_t::CFN_GIBBS_B2;
+                    cfn = BBPCostFunction::CFN_GIBBS_B2;
                     break;
                 case 2:
-                    cfn = bbp_cfn_t::CFN_GIBBS_EXP;
+                    cfn = BBPCostFunction::CFN_GIBBS_EXP;
                     break;
                 case 3:
-                    cfn = bbp_cfn_t::CFN_GIBBS_B_FACTOR;
+                    cfn = BBPCostFunction::CFN_GIBBS_B_FACTOR;
                     break;
                 case 4:
-                    cfn = bbp_cfn_t::CFN_GIBBS_B2_FACTOR;
+                    cfn = BBPCostFunction::CFN_GIBBS_B2_FACTOR;
                     break;
                 case 5:
-                    cfn = bbp_cfn_t::CFN_GIBBS_EXP_FACTOR;
+                    cfn = BBPCostFunction::CFN_GIBBS_EXP_FACTOR;
                     break;
                 case 6:
-                    cfn = bbp_cfn_t::CFN_VAR_ENT;
+                    cfn = BBPCostFunction::CFN_VAR_ENT;
                     break;
                 case 7:
-                    cfn = bbp_cfn_t::CFN_FACTOR_ENT;
+                    cfn = BBPCostFunction::CFN_FACTOR_ENT;
                     break;
                 case 8:
-                    cfn = bbp_cfn_t::CFN_BETHE_ENT;
+                    cfn = BBPCostFunction::CFN_BETHE_ENT;
                     break;
             }
 
-            double h = 1e-4;
-            double result = numericBBPTest( bp, &state, opts("updates",updates), cfn, h );
+            Real h = 1e-4;
+            Real result = numericBBPTest( bp, &state, opts("updates",updates), cfn, h );
             cout << "result: " << result << ",\tupdates=" << updates << ", cfn=" << cfn << endl;
         }
     }