fix testCSP by using the default key ordering.

release/4.3a0
Duy-Nguyen Ta 2013-10-11 17:48:44 +00:00
parent bf11f93cee
commit 1531abd285
3 changed files with 6 additions and 5 deletions

View File

@ -15,8 +15,8 @@ using namespace std;
namespace gtsam { namespace gtsam {
/// Find the best total assignment - can be expensive /// Find the best total assignment - can be expensive
CSP::sharedValues CSP::optimalAssignment() const { CSP::sharedValues CSP::optimalAssignment(OptionalOrdering ordering) const {
DiscreteBayesNet::shared_ptr chordal = this->eliminateSequential(); DiscreteBayesNet::shared_ptr chordal = this->eliminateSequential(ordering);
sharedValues mpe = chordal->optimize(); sharedValues mpe = chordal->optimize();
return mpe; return mpe;
} }

View File

@ -60,7 +60,7 @@ namespace gtsam {
// } // }
/// Find the best total assignment - can be expensive /// Find the best total assignment - can be expensive
sharedValues optimalAssignment() const; sharedValues optimalAssignment(OptionalOrdering ordering = boost::none) const;
// /* // /*
// * Perform loopy belief propagation // * Perform loopy belief propagation

View File

@ -116,7 +116,9 @@ TEST_UNSAFE( CSP, WesternUS)
csp.addAllDiff(CO,NM); csp.addAllDiff(CO,NM);
// Solve // 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); // GTSAM_PRINT(*mpe);
CSP::Values expected; CSP::Values expected;
insert(expected) insert(expected)
@ -127,7 +129,6 @@ TEST_UNSAFE( CSP, WesternUS)
// TODO: Fix me! mpe result seems to be right. (See the printing) // TODO: Fix me! mpe result seems to be right. (See the printing)
// It has the same prob as the expected solution. // It has the same prob as the expected solution.
// Is mpe another solution, or the expected solution is unique??? // Is mpe another solution, or the expected solution is unique???
cout << csp(*mpe) << " should be >= " << csp(expected) << endl;
EXPECT(assert_equal(expected,*mpe)); EXPECT(assert_equal(expected,*mpe));
EXPECT_DOUBLES_EQUAL(1, csp(*mpe), 1e-9); EXPECT_DOUBLES_EQUAL(1, csp(*mpe), 1e-9);