Removed workaround for old boost versions in discrete - we now require a higher version anyway

release/4.3a0
Alex Cunningham 2012-07-21 19:15:13 +00:00
parent 4b3edb0889
commit 5ff1870842
7 changed files with 19 additions and 56 deletions

View File

@ -21,17 +21,13 @@
#include "Signature.h"
#ifdef BOOST_HAVE_PARSER
#include <boost/spirit/include/qi.hpp> // for parsing
#include <boost/spirit/include/phoenix.hpp> // for qi::_val
#endif
namespace gtsam {
using namespace std;
#ifdef BOOST_HAVE_PARSER
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
@ -109,7 +105,6 @@ namespace gtsam {
return true;
}
} // \namespace parser
#endif
ostream& operator <<(ostream &os, const Signature::Row &row) {
os << row[0];
@ -169,7 +164,6 @@ namespace gtsam {
Signature& Signature::operator=(const string& spec) {
spec_.reset(spec);
#ifdef BOOST_HAVE_PARSER
Table table;
// NOTE: using simpler parse function to ensure boost back compatibility
// parser::It f = spec.begin(), l = spec.end();
@ -181,7 +175,6 @@ namespace gtsam {
normalize(row);
table_.reset(table);
}
#endif
return *this;
}

View File

@ -22,11 +22,6 @@
#include <boost/optional.hpp>
#include <gtsam/discrete/DiscreteKey.h>
#include <boost/version.hpp> // for checking whether we are using boost 1.40
#if BOOST_VERSION >= 104200
#define BOOST_HAVE_PARSER
#endif
namespace gtsam {
/**

View File

@ -23,10 +23,6 @@
#include <gtsam/discrete/AlgebraicDecisionTree.h>
#include <gtsam/discrete/DecisionTree-inl.h> // for convert only
#define DISABLE_TIMING
#include <boost/version.hpp> // for checking whether we are using boost 1.40
#if BOOST_VERSION >= 104200
#define BOOST_HAVE_PARSER
#endif
#include <boost/timer.hpp>
#include <boost/foreach.hpp>
@ -150,7 +146,6 @@ TEST(ADT, joint)
{
DiscreteKey A(0, 2), S(1, 2), T(2, 2), L(3, 2), B(4, 2), E(5, 2), X(6, 2), D(7, 2);
#ifdef BOOST_HAVE_PARSER
resetCounts();
ADT pA = create(A % "99/1");
ADT pS = create(S % "50/50");
@ -193,7 +188,6 @@ TEST(ADT, joint)
EXPECT(assert_equal(pA, fAa));
ADT fAb = pASTL.combine(S, &add_).combine(T, &add_).combine(L, &add_);
EXPECT(assert_equal(pA, fAb));
#endif
}
/* ************************************************************************* */
@ -203,7 +197,6 @@ TEST(ADT, inference)
DiscreteKey A(0,2), D(1,2),//
B(2,2), L(3,2), E(4,2), S(5,2), T(6,2), X(7,2);
#ifdef BOOST_HAVE_PARSER
resetCounts();
ADT pA = create(A % "99/1");
ADT pS = create(S % "50/50");
@ -247,7 +240,6 @@ TEST(ADT, inference)
dot(marginal, "Joint-Sum-ADBL");
EXPECT_LONGS_EQUAL(161, adds);
printCounts("Asia sum");
#endif
}
/* ************************************************************************* */
@ -255,7 +247,6 @@ TEST(ADT, factor_graph)
{
DiscreteKey B(0,2), L(1,2), E(2,2), S(3,2), T(4,2), X(5,2);
#ifdef BOOST_HAVE_PARSER
resetCounts();
ADT pS = create(S % "50/50");
ADT pT = create(T % "95/5");
@ -334,7 +325,6 @@ TEST(ADT, factor_graph)
fB = fB.combine(L, &add_);
dot(fB, "Eliminate-10-fB");
printCounts("Eliminate L");
#endif
}
/* ************************************************************************* */
@ -360,7 +350,6 @@ TEST(ADT, equality_noparser)
}
/* ************************************************************************* */
#ifdef BOOST_HAVE_PARSER
// test equality
TEST(ADT, equality_parser)
{
@ -376,7 +365,6 @@ TEST(ADT, equality_parser)
ADT pAB2 = apply(pB, pA1, &mul);
EXPECT(pAB2 == pAB1);
}
#endif
/* ******************************************************************************** */
// Factor graph construction

View File

@ -25,10 +25,6 @@
#include <boost/assign/std/map.hpp>
using namespace boost::assign;
#include <boost/version.hpp> // for checking whether we are using boost 1.40
#if BOOST_VERSION >= 104200
#define BOOST_HAVE_PARSER
#endif
#include <iostream>
@ -44,7 +40,6 @@ TEST(DiscreteBayesNet, Asia)
DiscreteKey A(0,2), S(4,2), T(3,2), L(6,2), B(7,2), E(5,2), X(2,2), D(1,2);
// TODO: make a version that doesn't use the parser
#ifdef BOOST_HAVE_PARSER
add_front(asia, A % "99/1");
add_front(asia, S % "50/50");
@ -104,7 +99,6 @@ TEST(DiscreteBayesNet, Asia)
S.first, 1)(E.first, 0)(L.first, 0)(B.first, 1);
DiscreteFactor::sharedValues actualSample = sample(*chordal2);
EXPECT(assert_equal(expectedSample, *actualSample));
#endif
}
/* ************************************************************************* */
@ -114,7 +108,6 @@ TEST_UNSAFE(DiscreteBayesNet, Sugar)
DiscreteBayesNet bn;
#ifdef BOOST_HAVE_PARSER
// test some mistakes
// add(bn, D);
// add(bn, D | E);
@ -127,7 +120,6 @@ TEST_UNSAFE(DiscreteBayesNet, Sugar)
// // try multivalued
add(bn, C % "1/1/2");
add(bn, C | S = "1/1/2 5/2/3");
#endif
}
/* ************************************************************************* */

View File

@ -24,10 +24,6 @@ using namespace boost::assign;
#include <CppUnitLite/TestHarness.h>
#include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/discrete/DiscreteConditional.h>
#include <boost/version.hpp> // for checking whether we are using boost 1.40
#if BOOST_VERSION >= 104200
#define BOOST_HAVE_PARSER
#endif
using namespace std;
using namespace gtsam;
@ -37,17 +33,31 @@ TEST( DiscreteConditionalTest, constructors)
{
DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
#ifdef BOOST_HAVE_PARSER
DiscreteConditional::shared_ptr expected1 = //
boost::make_shared<DiscreteConditional>(X | Y = "1/1 2/3 1/4");
#else
EXPECT(expected1);
DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
DiscreteConditional actual1(1, f1);
EXPECT(assert_equal(*expected1, actual1, 1e-9));
DecisionTreeFactor f2(X & Y & Z,
"0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
DiscreteConditional actual2(1, f2);
DecisionTreeFactor::shared_ptr actual2factor = actual2.toFactor();
// EXPECT(assert_equal(f2, *actual2factor, 1e-9));
}
/* ************************************************************************* */
TEST( DiscreteConditionalTest, constructors_alt_interface)
{
DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
Signature::Table table;
Signature::Row r1, r2, r3;
r1 += 1.0, 1.0; r2 += 2.0, 3.0; r3 += 1.0, 4.0;
table += r1, r2, r3;
DiscreteConditional::shared_ptr expected1 = //
boost::make_shared<DiscreteConditional>(X | Y = table);
#endif
EXPECT(expected1);
DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
DiscreteConditional actual1(1, f1);
@ -63,7 +73,6 @@ TEST( DiscreteConditionalTest, constructors)
/* ************************************************************************* */
TEST( DiscreteConditionalTest, constructors2)
{
#ifdef BOOST_HAVE_PARSER
// Declare keys and ordering
DiscreteKey C(0,2), B(1,2);
DecisionTreeFactor expected(C & B, "0.8 0.75 0.2 0.25");
@ -71,13 +80,11 @@ TEST( DiscreteConditionalTest, constructors2)
DiscreteConditional actual(signature);
DecisionTreeFactor::shared_ptr actualFactor = actual.toFactor();
EXPECT(assert_equal(expected, *actualFactor));
#endif
}
}
/* ************************************************************************* */
TEST( DiscreteConditionalTest, constructors3)
{
#ifdef BOOST_HAVE_PARSER
// Declare keys and ordering
DiscreteKey C(0,2), B(1,2), A(2,2);
DecisionTreeFactor expected(C & B & A, "0.8 0.5 0.5 0.2 0.2 0.5 0.5 0.8");
@ -85,13 +92,9 @@ TEST( DiscreteConditionalTest, constructors3)
DiscreteConditional actual(signature);
DecisionTreeFactor::shared_ptr actualFactor = actual.toFactor();
EXPECT(assert_equal(expected, *actualFactor));
#endif
}
/* ************************************************************************* */
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
/* ************************************************************************* */

View File

@ -24,10 +24,6 @@
#include <boost/assign/std/map.hpp>
using namespace boost::assign;
#include <boost/version.hpp> // for checking whether we are using boost 1.40
#if BOOST_VERSION >= 104200
#define BOOST_HAVE_PARSER
#endif
using namespace std;
using namespace gtsam;
@ -136,7 +132,6 @@ TEST( DiscreteFactorGraph, test)
boost::tie(conditional, newFactor) =//
EliminateDiscrete(graph, 1);
#ifdef BOOST_HAVE_PARSER
// Check Bayes net
CHECK(conditional);
DiscreteBayesNet expected;
@ -173,7 +168,6 @@ TEST( DiscreteFactorGraph, test)
insert(expectedValues)(0, 0)(1, 0)(2, 0);
DiscreteFactor::sharedValues actualValues = solver.optimize();
EXPECT(assert_equal(expectedValues, *actualValues));
#endif
}
/* ************************************************************************* */

View File

@ -28,7 +28,6 @@ using namespace boost::assign;
DiscreteKey X(0,2), Y(1,3), Z(2,2);
#ifdef BOOST_HAVE_PARSER
/* ************************************************************************* */
TEST(testSignature, simple_conditional) {
Signature sig(X | Y = "1/1 2/3 1/4");
@ -43,7 +42,6 @@ TEST(testSignature, simple_conditional) {
vector<double> actCpt = sig.cpt();
EXPECT_LONGS_EQUAL(6, actCpt.size());
}
#endif
/* ************************************************************************* */
TEST(testSignature, simple_conditional_nonparser) {