From b857dab6a941067f20c677eb032606d34197a428 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Wed, 17 Jul 2013 03:13:00 +0000 Subject: [PATCH] Renamed unit tests already converted to 'Obsolete' --- ...ayesTree.cpp => testBayesTreeObsolete.cpp} | 0 ...erTree.cpp => testClusterTreeObsolete.cpp} | 0 ...tional.cpp => testConditionalObsolete.cpp} | 0 ...ee.cpp => testEliminationTreeObsolete.cpp} | 0 ...rGraph.cpp => testFactorGraphObsolete.cpp} | 0 ...nTree.cpp => testJunctionTreeObsolete.cpp} | 0 ...tation.cpp => testPermutationObsolete.cpp} | 0 ...t.cpp => testSymbolicBayesNetObsolete.cpp} | 0 ....cpp => testSymbolicBayesTreeObsolete.cpp} | 0 ...pp => testSymbolicFactorGraphObsolete.cpp} | 0 ...tor.cpp => testSymbolicFactorObsolete.cpp} | 0 ... testSymbolicSequentialSolverObsolete.cpp} | 0 ...ndex.cpp => testVariableIndexObsolete.cpp} | 0 ...pp => testGaussianConditionalObsolete.cpp} | 0 ...pp => testGaussianFactorGraphObsolete.cpp} | 158 +++++++++--------- ...tor.cpp => testJacobianFactorObsolete.cpp} | 0 ...alues.cpp => testVectorValuesObsolete.cpp} | 0 ...t.cpp => testGaussianBayesNetObsolete.cpp} | 0 ...tor.cpp => testGaussianFactorObsolete.cpp} | 0 ....cpp => testSymbolicBayesNetBObsolete.cpp} | 0 ...p => testSymbolicFactorGraphBObsolete.cpp} | 0 21 files changed, 79 insertions(+), 79 deletions(-) rename gtsam/inference/tests/{testBayesTree.cpp => testBayesTreeObsolete.cpp} (100%) rename gtsam/inference/tests/{testClusterTree.cpp => testClusterTreeObsolete.cpp} (100%) rename gtsam/inference/tests/{testConditional.cpp => testConditionalObsolete.cpp} (100%) rename gtsam/inference/tests/{testEliminationTree.cpp => testEliminationTreeObsolete.cpp} (100%) rename gtsam/inference/tests/{testFactorGraph.cpp => testFactorGraphObsolete.cpp} (100%) rename gtsam/inference/tests/{testJunctionTree.cpp => testJunctionTreeObsolete.cpp} (100%) rename gtsam/inference/tests/{testPermutation.cpp => testPermutationObsolete.cpp} (100%) rename gtsam/inference/tests/{testSymbolicBayesNet.cpp => testSymbolicBayesNetObsolete.cpp} (100%) rename gtsam/inference/tests/{testSymbolicBayesTree.cpp => testSymbolicBayesTreeObsolete.cpp} (100%) rename gtsam/inference/tests/{testSymbolicFactorGraph.cpp => testSymbolicFactorGraphObsolete.cpp} (100%) rename gtsam/inference/tests/{testSymbolicFactor.cpp => testSymbolicFactorObsolete.cpp} (100%) rename gtsam/inference/tests/{testSymbolicSequentialSolver.cpp => testSymbolicSequentialSolverObsolete.cpp} (100%) rename gtsam/inference/tests/{testVariableIndex.cpp => testVariableIndexObsolete.cpp} (100%) rename gtsam/linear/tests/{testGaussianConditional.cpp => testGaussianConditionalObsolete.cpp} (100%) rename gtsam/linear/tests/{testGaussianFactorGraph.cpp => testGaussianFactorGraphObsolete.cpp} (99%) rename gtsam/linear/tests/{testJacobianFactor.cpp => testJacobianFactorObsolete.cpp} (100%) rename gtsam/linear/tests/{testVectorValues.cpp => testVectorValuesObsolete.cpp} (100%) rename tests/{testGaussianBayesNet.cpp => testGaussianBayesNetObsolete.cpp} (100%) rename tests/{testGaussianFactor.cpp => testGaussianFactorObsolete.cpp} (100%) rename tests/{testSymbolicBayesNetB.cpp => testSymbolicBayesNetBObsolete.cpp} (100%) rename tests/{testSymbolicFactorGraphB.cpp => testSymbolicFactorGraphBObsolete.cpp} (100%) diff --git a/gtsam/inference/tests/testBayesTree.cpp b/gtsam/inference/tests/testBayesTreeObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testBayesTree.cpp rename to gtsam/inference/tests/testBayesTreeObsolete.cpp diff --git a/gtsam/inference/tests/testClusterTree.cpp b/gtsam/inference/tests/testClusterTreeObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testClusterTree.cpp rename to gtsam/inference/tests/testClusterTreeObsolete.cpp diff --git a/gtsam/inference/tests/testConditional.cpp b/gtsam/inference/tests/testConditionalObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testConditional.cpp rename to gtsam/inference/tests/testConditionalObsolete.cpp diff --git a/gtsam/inference/tests/testEliminationTree.cpp b/gtsam/inference/tests/testEliminationTreeObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testEliminationTree.cpp rename to gtsam/inference/tests/testEliminationTreeObsolete.cpp diff --git a/gtsam/inference/tests/testFactorGraph.cpp b/gtsam/inference/tests/testFactorGraphObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testFactorGraph.cpp rename to gtsam/inference/tests/testFactorGraphObsolete.cpp diff --git a/gtsam/inference/tests/testJunctionTree.cpp b/gtsam/inference/tests/testJunctionTreeObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testJunctionTree.cpp rename to gtsam/inference/tests/testJunctionTreeObsolete.cpp diff --git a/gtsam/inference/tests/testPermutation.cpp b/gtsam/inference/tests/testPermutationObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testPermutation.cpp rename to gtsam/inference/tests/testPermutationObsolete.cpp diff --git a/gtsam/inference/tests/testSymbolicBayesNet.cpp b/gtsam/inference/tests/testSymbolicBayesNetObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testSymbolicBayesNet.cpp rename to gtsam/inference/tests/testSymbolicBayesNetObsolete.cpp diff --git a/gtsam/inference/tests/testSymbolicBayesTree.cpp b/gtsam/inference/tests/testSymbolicBayesTreeObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testSymbolicBayesTree.cpp rename to gtsam/inference/tests/testSymbolicBayesTreeObsolete.cpp diff --git a/gtsam/inference/tests/testSymbolicFactorGraph.cpp b/gtsam/inference/tests/testSymbolicFactorGraphObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testSymbolicFactorGraph.cpp rename to gtsam/inference/tests/testSymbolicFactorGraphObsolete.cpp diff --git a/gtsam/inference/tests/testSymbolicFactor.cpp b/gtsam/inference/tests/testSymbolicFactorObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testSymbolicFactor.cpp rename to gtsam/inference/tests/testSymbolicFactorObsolete.cpp diff --git a/gtsam/inference/tests/testSymbolicSequentialSolver.cpp b/gtsam/inference/tests/testSymbolicSequentialSolverObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testSymbolicSequentialSolver.cpp rename to gtsam/inference/tests/testSymbolicSequentialSolverObsolete.cpp diff --git a/gtsam/inference/tests/testVariableIndex.cpp b/gtsam/inference/tests/testVariableIndexObsolete.cpp similarity index 100% rename from gtsam/inference/tests/testVariableIndex.cpp rename to gtsam/inference/tests/testVariableIndexObsolete.cpp diff --git a/gtsam/linear/tests/testGaussianConditional.cpp b/gtsam/linear/tests/testGaussianConditionalObsolete.cpp similarity index 100% rename from gtsam/linear/tests/testGaussianConditional.cpp rename to gtsam/linear/tests/testGaussianConditionalObsolete.cpp diff --git a/gtsam/linear/tests/testGaussianFactorGraph.cpp b/gtsam/linear/tests/testGaussianFactorGraphObsolete.cpp similarity index 99% rename from gtsam/linear/tests/testGaussianFactorGraph.cpp rename to gtsam/linear/tests/testGaussianFactorGraphObsolete.cpp index bdc64d849..827672631 100644 --- a/gtsam/linear/tests/testGaussianFactorGraph.cpp +++ b/gtsam/linear/tests/testGaussianFactorGraphObsolete.cpp @@ -37,18 +37,18 @@ static SharedDiagonal constraintModel = noiseModel::Constrained::All(2); static GaussianFactorGraph createSimpleGaussianFactorGraph() { - GaussianFactorGraph fg; - SharedDiagonal unit2 = noiseModel::Unit::Create(2); - // linearized prior on x1: c[_x1_]+x1=0 i.e. x1=-c[_x1_] - fg.add(2, 10*eye(2), -1.0*ones(2), unit2); - // odometry between x1 and x2: x2-x1=[0.2;-0.1] - fg.add(2, -10*eye(2), 0, 10*eye(2), Vector_(2, 2.0, -1.0), unit2); - // measurement between x1 and l1: l1-x1=[0.0;0.2] - fg.add(2, -5*eye(2), 1, 5*eye(2), Vector_(2, 0.0, 1.0), unit2); - // measurement between x2 and l1: l1-x2=[-0.2;0.3] - fg.add(0, -5*eye(2), 1, 5*eye(2), Vector_(2, -1.0, 1.5), unit2); - return fg; -} + GaussianFactorGraph fg; + SharedDiagonal unit2 = noiseModel::Unit::Create(2); + // linearized prior on x1: c[_x1_]+x1=0 i.e. x1=-c[_x1_] + fg.add(2, 10*eye(2), -1.0*ones(2), unit2); + // odometry between x1 and x2: x2-x1=[0.2;-0.1] + fg.add(2, -10*eye(2), 0, 10*eye(2), Vector_(2, 2.0, -1.0), unit2); + // measurement between x1 and l1: l1-x1=[0.0;0.2] + fg.add(2, -5*eye(2), 1, 5*eye(2), Vector_(2, 0.0, 1.0), unit2); + // measurement between x2 and l1: l1-x2=[-0.2;0.3] + fg.add(0, -5*eye(2), 1, 5*eye(2), Vector_(2, -1.0, 1.5), unit2); + return fg; +} /* ************************************************************************* */ @@ -464,73 +464,73 @@ TEST(GaussianFactorGraph, matrices) { EXPECT(assert_equal(expectedL, actualL)); EXPECT(assert_equal(expectedeta, actualeta)); } - -/* ************************************************************************* */ -TEST( GaussianFactorGraph, gradient ) -{ - GaussianFactorGraph fg = createSimpleGaussianFactorGraph(); - - // Construct expected gradient - VectorValues expected; - - // 2*f(x) = 100*(x1+c[X(1)])^2 + 100*(x2-x1-[0.2;-0.1])^2 + 25*(l1-x1-[0.0;0.2])^2 + 25*(l1-x2-[-0.2;0.3])^2 - // worked out: df/dx1 = 100*[0.1;0.1] + 100*[0.2;-0.1]) + 25*[0.0;0.2] = [10+20;10-10+5] = [30;5] - expected.insert(1,Vector_(2, 5.0,-12.5)); - expected.insert(2,Vector_(2, 30.0, 5.0)); - expected.insert(0,Vector_(2,-25.0, 17.5)); - - // Check the gradient at delta=0 - VectorValues zero = VectorValues::Zero(expected); - VectorValues actual = gradient(fg, zero); - EXPECT(assert_equal(expected,actual)); - - // Check the gradient at the solution (should be zero) - VectorValues solution = *GaussianSequentialSolver(fg).optimize(); - VectorValues actual2 = gradient(fg, solution); - EXPECT(assert_equal(VectorValues::Zero(solution), actual2)); -} - -/* ************************************************************************* */ -TEST( GaussianFactorGraph, transposeMultiplication ) -{ - GaussianFactorGraph A = createSimpleGaussianFactorGraph(); - - VectorValues e; - e.insert(0, Vector_(2, 0.0, 0.0)); - e.insert(1, Vector_(2,15.0, 0.0)); - e.insert(2, Vector_(2, 0.0,-5.0)); - e.insert(3, Vector_(2,-7.5,-5.0)); - - VectorValues expected; - expected.insert(1, Vector_(2, -37.5,-50.0)); - expected.insert(2, Vector_(2,-150.0, 25.0)); - expected.insert(0, Vector_(2, 187.5, 25.0)); - - VectorValues actual = VectorValues::SameStructure(expected); - transposeMultiply(A, e, actual); - EXPECT(assert_equal(expected,actual)); -} - -/* ************************************************************************* */ -TEST(GaussianFactorGraph, eliminate_empty ) -{ - // eliminate an empty factor - GaussianFactorGraph gfg; - gfg.push_back(boost::make_shared()); - GaussianConditional::shared_ptr actualCG; - GaussianFactorGraph remainingGFG; - boost::tie(actualCG, remainingGFG) = gfg.eliminateOne(0); - - // expected Conditional Gaussian is just a parent-less node with P(x)=1 - GaussianConditional expectedCG(0, Vector(), Matrix(), Vector()); - - // expected remaining graph should be the same as the original, still empty :-) - GaussianFactorGraph expectedLF = gfg; - - // check if the result matches - EXPECT(actualCG->equals(expectedCG)); - EXPECT(remainingGFG.equals(expectedLF)); -} + +/* ************************************************************************* */ +TEST( GaussianFactorGraph, gradient ) +{ + GaussianFactorGraph fg = createSimpleGaussianFactorGraph(); + + // Construct expected gradient + VectorValues expected; + + // 2*f(x) = 100*(x1+c[X(1)])^2 + 100*(x2-x1-[0.2;-0.1])^2 + 25*(l1-x1-[0.0;0.2])^2 + 25*(l1-x2-[-0.2;0.3])^2 + // worked out: df/dx1 = 100*[0.1;0.1] + 100*[0.2;-0.1]) + 25*[0.0;0.2] = [10+20;10-10+5] = [30;5] + expected.insert(1,Vector_(2, 5.0,-12.5)); + expected.insert(2,Vector_(2, 30.0, 5.0)); + expected.insert(0,Vector_(2,-25.0, 17.5)); + + // Check the gradient at delta=0 + VectorValues zero = VectorValues::Zero(expected); + VectorValues actual = gradient(fg, zero); + EXPECT(assert_equal(expected,actual)); + + // Check the gradient at the solution (should be zero) + VectorValues solution = *GaussianSequentialSolver(fg).optimize(); + VectorValues actual2 = gradient(fg, solution); + EXPECT(assert_equal(VectorValues::Zero(solution), actual2)); +} + +/* ************************************************************************* */ +TEST( GaussianFactorGraph, transposeMultiplication ) +{ + GaussianFactorGraph A = createSimpleGaussianFactorGraph(); + + VectorValues e; + e.insert(0, Vector_(2, 0.0, 0.0)); + e.insert(1, Vector_(2,15.0, 0.0)); + e.insert(2, Vector_(2, 0.0,-5.0)); + e.insert(3, Vector_(2,-7.5,-5.0)); + + VectorValues expected; + expected.insert(1, Vector_(2, -37.5,-50.0)); + expected.insert(2, Vector_(2,-150.0, 25.0)); + expected.insert(0, Vector_(2, 187.5, 25.0)); + + VectorValues actual = VectorValues::SameStructure(expected); + transposeMultiply(A, e, actual); + EXPECT(assert_equal(expected,actual)); +} + +/* ************************************************************************* */ +TEST(GaussianFactorGraph, eliminate_empty ) +{ + // eliminate an empty factor + GaussianFactorGraph gfg; + gfg.push_back(boost::make_shared()); + GaussianConditional::shared_ptr actualCG; + GaussianFactorGraph remainingGFG; + boost::tie(actualCG, remainingGFG) = gfg.eliminateOne(0); + + // expected Conditional Gaussian is just a parent-less node with P(x)=1 + GaussianConditional expectedCG(0, Vector(), Matrix(), Vector()); + + // expected remaining graph should be the same as the original, still empty :-) + GaussianFactorGraph expectedLF = gfg; + + // check if the result matches + EXPECT(actualCG->equals(expectedCG)); + EXPECT(remainingGFG.equals(expectedLF)); +} /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr);} diff --git a/gtsam/linear/tests/testJacobianFactor.cpp b/gtsam/linear/tests/testJacobianFactorObsolete.cpp similarity index 100% rename from gtsam/linear/tests/testJacobianFactor.cpp rename to gtsam/linear/tests/testJacobianFactorObsolete.cpp diff --git a/gtsam/linear/tests/testVectorValues.cpp b/gtsam/linear/tests/testVectorValuesObsolete.cpp similarity index 100% rename from gtsam/linear/tests/testVectorValues.cpp rename to gtsam/linear/tests/testVectorValuesObsolete.cpp diff --git a/tests/testGaussianBayesNet.cpp b/tests/testGaussianBayesNetObsolete.cpp similarity index 100% rename from tests/testGaussianBayesNet.cpp rename to tests/testGaussianBayesNetObsolete.cpp diff --git a/tests/testGaussianFactor.cpp b/tests/testGaussianFactorObsolete.cpp similarity index 100% rename from tests/testGaussianFactor.cpp rename to tests/testGaussianFactorObsolete.cpp diff --git a/tests/testSymbolicBayesNetB.cpp b/tests/testSymbolicBayesNetBObsolete.cpp similarity index 100% rename from tests/testSymbolicBayesNetB.cpp rename to tests/testSymbolicBayesNetBObsolete.cpp diff --git a/tests/testSymbolicFactorGraphB.cpp b/tests/testSymbolicFactorGraphBObsolete.cpp similarity index 100% rename from tests/testSymbolicFactorGraphB.cpp rename to tests/testSymbolicFactorGraphBObsolete.cpp