diff --git a/gtsam_unstable/discrete/CSP.cpp b/gtsam_unstable/discrete/CSP.cpp index 45164e203..ae716f246 100644 --- a/gtsam_unstable/discrete/CSP.cpp +++ b/gtsam_unstable/discrete/CSP.cpp @@ -15,8 +15,8 @@ using namespace std; namespace gtsam { /// Find the best total assignment - can be expensive - CSP::sharedValues CSP::optimalAssignment() const { - DiscreteBayesNet::shared_ptr chordal = this->eliminateSequential(); + CSP::sharedValues CSP::optimalAssignment(OptionalOrdering ordering) const { + DiscreteBayesNet::shared_ptr chordal = this->eliminateSequential(ordering); sharedValues mpe = chordal->optimize(); return mpe; } diff --git a/gtsam_unstable/discrete/CSP.h b/gtsam_unstable/discrete/CSP.h index 0786acbe7..ab3abffde 100644 --- a/gtsam_unstable/discrete/CSP.h +++ b/gtsam_unstable/discrete/CSP.h @@ -60,7 +60,7 @@ namespace gtsam { // } /// Find the best total assignment - can be expensive - sharedValues optimalAssignment() const; + sharedValues optimalAssignment(OptionalOrdering ordering = boost::none) const; // /* // * Perform loopy belief propagation diff --git a/gtsam_unstable/discrete/tests/testCSP.cpp b/gtsam_unstable/discrete/tests/testCSP.cpp index e987e9642..3dd493b1b 100644 --- a/gtsam_unstable/discrete/tests/testCSP.cpp +++ b/gtsam_unstable/discrete/tests/testCSP.cpp @@ -116,7 +116,9 @@ TEST_UNSAFE( CSP, WesternUS) csp.addAllDiff(CO,NM); // Solve - CSP::sharedValues mpe = csp.optimalAssignment(); + Ordering ordering; + ordering += Key(0),Key(1),Key(2),Key(3),Key(4),Key(5),Key(6),Key(7),Key(8),Key(9),Key(10); + CSP::sharedValues mpe = csp.optimalAssignment(ordering); // GTSAM_PRINT(*mpe); CSP::Values expected; insert(expected) @@ -127,7 +129,6 @@ TEST_UNSAFE( CSP, WesternUS) // TODO: Fix me! mpe result seems to be right. (See the printing) // It has the same prob as the expected solution. // Is mpe another solution, or the expected solution is unique??? - cout << csp(*mpe) << " should be >= " << csp(expected) << endl; EXPECT(assert_equal(expected,*mpe)); EXPECT_DOUBLES_EQUAL(1, csp(*mpe), 1e-9);