undo dot changes
parent
ed839083e2
commit
9982057a2b
|
@ -48,7 +48,7 @@ template<> struct traits<ADT> : public Testable<ADT> {};
|
||||||
#define DISABLE_DOT
|
#define DISABLE_DOT
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void DOT(const T&f, const string& filename) {
|
void dot(const T&f, const string& filename) {
|
||||||
#ifndef DISABLE_DOT
|
#ifndef DISABLE_DOT
|
||||||
f.dot(filename);
|
f.dot(filename);
|
||||||
#endif
|
#endif
|
||||||
|
@ -112,7 +112,7 @@ TEST(ADT, example3)
|
||||||
ADT note(E, 0.9, 0.1);
|
ADT note(E, 0.9, 0.1);
|
||||||
|
|
||||||
ADT cnotb = c * notb;
|
ADT cnotb = c * notb;
|
||||||
DOT(cnotb, "ADT-cnotb");
|
dot(cnotb, "ADT-cnotb");
|
||||||
|
|
||||||
// a.print("a: ");
|
// a.print("a: ");
|
||||||
// cnotb.print("cnotb: ");
|
// cnotb.print("cnotb: ");
|
||||||
|
@ -120,11 +120,11 @@ TEST(ADT, example3)
|
||||||
// acnotb.print("acnotb: ");
|
// acnotb.print("acnotb: ");
|
||||||
// acnotb.printCache("acnotb Cache:");
|
// acnotb.printCache("acnotb Cache:");
|
||||||
|
|
||||||
DOT(acnotb, "ADT-acnotb");
|
dot(acnotb, "ADT-acnotb");
|
||||||
|
|
||||||
|
|
||||||
ADT big = apply(apply(d, note, &mul), acnotb, &add_);
|
ADT big = apply(apply(d, note, &mul), acnotb, &add_);
|
||||||
DOT(big, "ADT-big");
|
dot(big, "ADT-big");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******************************************************************************** */
|
/* ******************************************************************************** */
|
||||||
|
@ -137,7 +137,7 @@ ADT create(const Signature& signature) {
|
||||||
static size_t count = 0;
|
static size_t count = 0;
|
||||||
const DiscreteKey& key = signature.key();
|
const DiscreteKey& key = signature.key();
|
||||||
string DOTfile = (boost::format("CPT-%03d-%d") % ++count % key.first).str();
|
string DOTfile = (boost::format("CPT-%03d-%d") % ++count % key.first).str();
|
||||||
DOT(p, DOTfile);
|
dot(p, DOTfile);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,21 +167,21 @@ TEST(ADT, joint)
|
||||||
resetCounts();
|
resetCounts();
|
||||||
gttic_(asiaJoint);
|
gttic_(asiaJoint);
|
||||||
ADT joint = pA;
|
ADT joint = pA;
|
||||||
DOT(joint, "Asia-A");
|
dot(joint, "Asia-A");
|
||||||
joint = apply(joint, pS, &mul);
|
joint = apply(joint, pS, &mul);
|
||||||
DOT(joint, "Asia-AS");
|
dot(joint, "Asia-AS");
|
||||||
joint = apply(joint, pT, &mul);
|
joint = apply(joint, pT, &mul);
|
||||||
DOT(joint, "Asia-AST");
|
dot(joint, "Asia-AST");
|
||||||
joint = apply(joint, pL, &mul);
|
joint = apply(joint, pL, &mul);
|
||||||
DOT(joint, "Asia-ASTL");
|
dot(joint, "Asia-ASTL");
|
||||||
joint = apply(joint, pB, &mul);
|
joint = apply(joint, pB, &mul);
|
||||||
DOT(joint, "Asia-ASTLB");
|
dot(joint, "Asia-ASTLB");
|
||||||
joint = apply(joint, pE, &mul);
|
joint = apply(joint, pE, &mul);
|
||||||
DOT(joint, "Asia-ASTLBE");
|
dot(joint, "Asia-ASTLBE");
|
||||||
joint = apply(joint, pX, &mul);
|
joint = apply(joint, pX, &mul);
|
||||||
DOT(joint, "Asia-ASTLBEX");
|
dot(joint, "Asia-ASTLBEX");
|
||||||
joint = apply(joint, pD, &mul);
|
joint = apply(joint, pD, &mul);
|
||||||
DOT(joint, "Asia-ASTLBEXD");
|
dot(joint, "Asia-ASTLBEXD");
|
||||||
EXPECT_LONGS_EQUAL(346, muls);
|
EXPECT_LONGS_EQUAL(346, muls);
|
||||||
gttoc_(asiaJoint);
|
gttoc_(asiaJoint);
|
||||||
tictoc_getNode(asiaJointNode, asiaJoint);
|
tictoc_getNode(asiaJointNode, asiaJoint);
|
||||||
|
@ -229,21 +229,21 @@ TEST(ADT, inference)
|
||||||
resetCounts();
|
resetCounts();
|
||||||
gttic_(asiaProd);
|
gttic_(asiaProd);
|
||||||
ADT joint = pA;
|
ADT joint = pA;
|
||||||
DOT(joint, "Joint-Product-A");
|
dot(joint, "Joint-Product-A");
|
||||||
joint = apply(joint, pS, &mul);
|
joint = apply(joint, pS, &mul);
|
||||||
DOT(joint, "Joint-Product-AS");
|
dot(joint, "Joint-Product-AS");
|
||||||
joint = apply(joint, pT, &mul);
|
joint = apply(joint, pT, &mul);
|
||||||
DOT(joint, "Joint-Product-AST");
|
dot(joint, "Joint-Product-AST");
|
||||||
joint = apply(joint, pL, &mul);
|
joint = apply(joint, pL, &mul);
|
||||||
DOT(joint, "Joint-Product-ASTL");
|
dot(joint, "Joint-Product-ASTL");
|
||||||
joint = apply(joint, pB, &mul);
|
joint = apply(joint, pB, &mul);
|
||||||
DOT(joint, "Joint-Product-ASTLB");
|
dot(joint, "Joint-Product-ASTLB");
|
||||||
joint = apply(joint, pE, &mul);
|
joint = apply(joint, pE, &mul);
|
||||||
DOT(joint, "Joint-Product-ASTLBE");
|
dot(joint, "Joint-Product-ASTLBE");
|
||||||
joint = apply(joint, pX, &mul);
|
joint = apply(joint, pX, &mul);
|
||||||
DOT(joint, "Joint-Product-ASTLBEX");
|
dot(joint, "Joint-Product-ASTLBEX");
|
||||||
joint = apply(joint, pD, &mul);
|
joint = apply(joint, pD, &mul);
|
||||||
DOT(joint, "Joint-Product-ASTLBEXD");
|
dot(joint, "Joint-Product-ASTLBEXD");
|
||||||
EXPECT_LONGS_EQUAL(370, (long)muls); // different ordering
|
EXPECT_LONGS_EQUAL(370, (long)muls); // different ordering
|
||||||
gttoc_(asiaProd);
|
gttoc_(asiaProd);
|
||||||
tictoc_getNode(asiaProdNode, asiaProd);
|
tictoc_getNode(asiaProdNode, asiaProd);
|
||||||
|
@ -255,13 +255,13 @@ TEST(ADT, inference)
|
||||||
gttic_(asiaSum);
|
gttic_(asiaSum);
|
||||||
ADT marginal = joint;
|
ADT marginal = joint;
|
||||||
marginal = marginal.combine(X, &add_);
|
marginal = marginal.combine(X, &add_);
|
||||||
DOT(marginal, "Joint-Sum-ADBLEST");
|
dot(marginal, "Joint-Sum-ADBLEST");
|
||||||
marginal = marginal.combine(T, &add_);
|
marginal = marginal.combine(T, &add_);
|
||||||
DOT(marginal, "Joint-Sum-ADBLES");
|
dot(marginal, "Joint-Sum-ADBLES");
|
||||||
marginal = marginal.combine(S, &add_);
|
marginal = marginal.combine(S, &add_);
|
||||||
DOT(marginal, "Joint-Sum-ADBLE");
|
dot(marginal, "Joint-Sum-ADBLE");
|
||||||
marginal = marginal.combine(E, &add_);
|
marginal = marginal.combine(E, &add_);
|
||||||
DOT(marginal, "Joint-Sum-ADBL");
|
dot(marginal, "Joint-Sum-ADBL");
|
||||||
EXPECT_LONGS_EQUAL(161, (long)adds);
|
EXPECT_LONGS_EQUAL(161, (long)adds);
|
||||||
gttoc_(asiaSum);
|
gttoc_(asiaSum);
|
||||||
tictoc_getNode(asiaSumNode, asiaSum);
|
tictoc_getNode(asiaSumNode, asiaSum);
|
||||||
|
@ -300,7 +300,7 @@ TEST(ADT, factor_graph)
|
||||||
fg = apply(fg, pE, &mul);
|
fg = apply(fg, pE, &mul);
|
||||||
fg = apply(fg, pX, &mul);
|
fg = apply(fg, pX, &mul);
|
||||||
fg = apply(fg, pD, &mul);
|
fg = apply(fg, pD, &mul);
|
||||||
DOT(fg, "FactorGraph");
|
dot(fg, "FactorGraph");
|
||||||
EXPECT_LONGS_EQUAL(158, (long)muls);
|
EXPECT_LONGS_EQUAL(158, (long)muls);
|
||||||
gttoc_(asiaFG);
|
gttoc_(asiaFG);
|
||||||
tictoc_getNode(asiaFGNode, asiaFG);
|
tictoc_getNode(asiaFGNode, asiaFG);
|
||||||
|
@ -311,15 +311,15 @@ TEST(ADT, factor_graph)
|
||||||
resetCounts();
|
resetCounts();
|
||||||
gttic_(marg);
|
gttic_(marg);
|
||||||
fg = fg.combine(X, &add_);
|
fg = fg.combine(X, &add_);
|
||||||
DOT(fg, "Marginalized-6X");
|
dot(fg, "Marginalized-6X");
|
||||||
fg = fg.combine(T, &add_);
|
fg = fg.combine(T, &add_);
|
||||||
DOT(fg, "Marginalized-5T");
|
dot(fg, "Marginalized-5T");
|
||||||
fg = fg.combine(S, &add_);
|
fg = fg.combine(S, &add_);
|
||||||
DOT(fg, "Marginalized-4S");
|
dot(fg, "Marginalized-4S");
|
||||||
fg = fg.combine(E, &add_);
|
fg = fg.combine(E, &add_);
|
||||||
DOT(fg, "Marginalized-3E");
|
dot(fg, "Marginalized-3E");
|
||||||
fg = fg.combine(L, &add_);
|
fg = fg.combine(L, &add_);
|
||||||
DOT(fg, "Marginalized-2L");
|
dot(fg, "Marginalized-2L");
|
||||||
EXPECT(adds = 54);
|
EXPECT(adds = 54);
|
||||||
gttoc_(marg);
|
gttoc_(marg);
|
||||||
tictoc_getNode(margNode, marg);
|
tictoc_getNode(margNode, marg);
|
||||||
|
@ -333,9 +333,9 @@ TEST(ADT, factor_graph)
|
||||||
resetCounts();
|
resetCounts();
|
||||||
gttic_(elimX);
|
gttic_(elimX);
|
||||||
ADT fE = pX;
|
ADT fE = pX;
|
||||||
DOT(fE, "Eliminate-01-fEX");
|
dot(fE, "Eliminate-01-fEX");
|
||||||
fE = fE.combine(X, &add_);
|
fE = fE.combine(X, &add_);
|
||||||
DOT(fE, "Eliminate-02-fE");
|
dot(fE, "Eliminate-02-fE");
|
||||||
gttoc_(elimX);
|
gttoc_(elimX);
|
||||||
tictoc_getNode(elimXNode, elimX);
|
tictoc_getNode(elimXNode, elimX);
|
||||||
elapsed = elimXNode->secs() + elimXNode->wall();
|
elapsed = elimXNode->secs() + elimXNode->wall();
|
||||||
|
@ -347,9 +347,9 @@ TEST(ADT, factor_graph)
|
||||||
gttic_(elimT);
|
gttic_(elimT);
|
||||||
ADT fLE = pT;
|
ADT fLE = pT;
|
||||||
fLE = apply(fLE, pE, &mul);
|
fLE = apply(fLE, pE, &mul);
|
||||||
DOT(fLE, "Eliminate-03-fLET");
|
dot(fLE, "Eliminate-03-fLET");
|
||||||
fLE = fLE.combine(T, &add_);
|
fLE = fLE.combine(T, &add_);
|
||||||
DOT(fLE, "Eliminate-04-fLE");
|
dot(fLE, "Eliminate-04-fLE");
|
||||||
gttoc_(elimT);
|
gttoc_(elimT);
|
||||||
tictoc_getNode(elimTNode, elimT);
|
tictoc_getNode(elimTNode, elimT);
|
||||||
elapsed = elimTNode->secs() + elimTNode->wall();
|
elapsed = elimTNode->secs() + elimTNode->wall();
|
||||||
|
@ -362,9 +362,9 @@ TEST(ADT, factor_graph)
|
||||||
ADT fBL = pS;
|
ADT fBL = pS;
|
||||||
fBL = apply(fBL, pL, &mul);
|
fBL = apply(fBL, pL, &mul);
|
||||||
fBL = apply(fBL, pB, &mul);
|
fBL = apply(fBL, pB, &mul);
|
||||||
DOT(fBL, "Eliminate-05-fBLS");
|
dot(fBL, "Eliminate-05-fBLS");
|
||||||
fBL = fBL.combine(S, &add_);
|
fBL = fBL.combine(S, &add_);
|
||||||
DOT(fBL, "Eliminate-06-fBL");
|
dot(fBL, "Eliminate-06-fBL");
|
||||||
gttoc_(elimS);
|
gttoc_(elimS);
|
||||||
tictoc_getNode(elimSNode, elimS);
|
tictoc_getNode(elimSNode, elimS);
|
||||||
elapsed = elimSNode->secs() + elimSNode->wall();
|
elapsed = elimSNode->secs() + elimSNode->wall();
|
||||||
|
@ -377,9 +377,9 @@ TEST(ADT, factor_graph)
|
||||||
ADT fBL2 = fE;
|
ADT fBL2 = fE;
|
||||||
fBL2 = apply(fBL2, fLE, &mul);
|
fBL2 = apply(fBL2, fLE, &mul);
|
||||||
fBL2 = apply(fBL2, pD, &mul);
|
fBL2 = apply(fBL2, pD, &mul);
|
||||||
DOT(fBL2, "Eliminate-07-fBLE");
|
dot(fBL2, "Eliminate-07-fBLE");
|
||||||
fBL2 = fBL2.combine(E, &add_);
|
fBL2 = fBL2.combine(E, &add_);
|
||||||
DOT(fBL2, "Eliminate-08-fBL2");
|
dot(fBL2, "Eliminate-08-fBL2");
|
||||||
gttoc_(elimE);
|
gttoc_(elimE);
|
||||||
tictoc_getNode(elimENode, elimE);
|
tictoc_getNode(elimENode, elimE);
|
||||||
elapsed = elimENode->secs() + elimENode->wall();
|
elapsed = elimENode->secs() + elimENode->wall();
|
||||||
|
@ -391,9 +391,9 @@ TEST(ADT, factor_graph)
|
||||||
gttic_(elimL);
|
gttic_(elimL);
|
||||||
ADT fB = fBL;
|
ADT fB = fBL;
|
||||||
fB = apply(fB, fBL2, &mul);
|
fB = apply(fB, fBL2, &mul);
|
||||||
DOT(fB, "Eliminate-09-fBL");
|
dot(fB, "Eliminate-09-fBL");
|
||||||
fB = fB.combine(L, &add_);
|
fB = fB.combine(L, &add_);
|
||||||
DOT(fB, "Eliminate-10-fB");
|
dot(fB, "Eliminate-10-fB");
|
||||||
gttoc_(elimL);
|
gttoc_(elimL);
|
||||||
tictoc_getNode(elimLNode, elimL);
|
tictoc_getNode(elimLNode, elimL);
|
||||||
elapsed = elimLNode->secs() + elimLNode->wall();
|
elapsed = elimLNode->secs() + elimLNode->wall();
|
||||||
|
@ -414,13 +414,13 @@ TEST(ADT, equality_noparser)
|
||||||
// Check straight equality
|
// Check straight equality
|
||||||
ADT pA1 = create(A % tableA);
|
ADT pA1 = create(A % tableA);
|
||||||
ADT pA2 = create(A % tableA);
|
ADT pA2 = create(A % tableA);
|
||||||
EXPECT(pA1 == pA2); // should be equal
|
EXPECT(pA1.equals(pA2)); // should be equal
|
||||||
|
|
||||||
// Check equality after apply
|
// Check equality after apply
|
||||||
ADT pB = create(B % tableB);
|
ADT pB = create(B % tableB);
|
||||||
ADT pAB1 = apply(pA1, pB, &mul);
|
ADT pAB1 = apply(pA1, pB, &mul);
|
||||||
ADT pAB2 = apply(pB, pA1, &mul);
|
ADT pAB2 = apply(pB, pA1, &mul);
|
||||||
EXPECT(pAB2 == pAB1);
|
EXPECT(pAB2.equals(pAB1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -431,13 +431,13 @@ TEST(ADT, equality_parser)
|
||||||
// Check straight equality
|
// Check straight equality
|
||||||
ADT pA1 = create(A % "80/20");
|
ADT pA1 = create(A % "80/20");
|
||||||
ADT pA2 = create(A % "80/20");
|
ADT pA2 = create(A % "80/20");
|
||||||
EXPECT(pA1 == pA2); // should be equal
|
EXPECT(pA1.equals(pA2)); // should be equal
|
||||||
|
|
||||||
// Check equality after apply
|
// Check equality after apply
|
||||||
ADT pB = create(B % "60/40");
|
ADT pB = create(B % "60/40");
|
||||||
ADT pAB1 = apply(pA1, pB, &mul);
|
ADT pAB1 = apply(pA1, pB, &mul);
|
||||||
ADT pAB2 = apply(pB, pA1, &mul);
|
ADT pAB2 = apply(pB, pA1, &mul);
|
||||||
EXPECT(pAB2 == pAB1);
|
EXPECT(pAB2.equals(pAB1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******************************************************************************** */
|
/* ******************************************************************************** */
|
||||||
|
@ -491,7 +491,7 @@ TEST(ADT, conversion)
|
||||||
{
|
{
|
||||||
DiscreteKey X(0,2), Y(1,2);
|
DiscreteKey X(0,2), Y(1,2);
|
||||||
ADT fDiscreteKey(X & Y, "0.2 0.5 0.3 0.6");
|
ADT fDiscreteKey(X & Y, "0.2 0.5 0.3 0.6");
|
||||||
DOT(fDiscreteKey, "conversion-f1");
|
dot(fDiscreteKey, "conversion-f1");
|
||||||
|
|
||||||
std::map<Key, Key> keyMap;
|
std::map<Key, Key> keyMap;
|
||||||
keyMap[0] = 5;
|
keyMap[0] = 5;
|
||||||
|
@ -500,7 +500,7 @@ TEST(ADT, conversion)
|
||||||
AlgebraicDecisionTree<Key> fIndexKey(fDiscreteKey, keyMap);
|
AlgebraicDecisionTree<Key> fIndexKey(fDiscreteKey, keyMap);
|
||||||
// f1.print("f1");
|
// f1.print("f1");
|
||||||
// f2.print("f2");
|
// f2.print("f2");
|
||||||
DOT(fIndexKey, "conversion-f2");
|
dot(fIndexKey, "conversion-f2");
|
||||||
|
|
||||||
DiscreteValues x00, x01, x02, x10, x11, x12;
|
DiscreteValues x00, x01, x02, x10, x11, x12;
|
||||||
x00[5] = 0, x00[2] = 0;
|
x00[5] = 0, x00[2] = 0;
|
||||||
|
@ -519,7 +519,7 @@ TEST(ADT, elimination)
|
||||||
{
|
{
|
||||||
DiscreteKey A(0,2), B(1,3), C(2,2);
|
DiscreteKey A(0,2), B(1,3), C(2,2);
|
||||||
ADT f1(A & B & C, "1 2 3 4 5 6 1 8 3 3 5 5");
|
ADT f1(A & B & C, "1 2 3 4 5 6 1 8 3 3 5 5");
|
||||||
DOT(f1, "elimination-f1");
|
dot(f1, "elimination-f1");
|
||||||
|
|
||||||
{
|
{
|
||||||
// sum out lower key
|
// sum out lower key
|
||||||
|
|
|
@ -32,13 +32,13 @@ using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void write_dot(const T&f, const string& filename) {
|
void dot(const T&f, const string& filename) {
|
||||||
#ifndef DISABLE_DOT
|
#ifndef DISABLE_DOT
|
||||||
f.dot(filename);
|
f.dot(filename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DOT(x)(write_dot(x,#x))
|
#define DOT(x)(dot(x,#x))
|
||||||
|
|
||||||
struct Crazy { int a; double b; };
|
struct Crazy { int a; double b; };
|
||||||
typedef DecisionTree<string,Crazy> CrazyDecisionTree; // check that DecisionTree is actually generic (as it pretends to be)
|
typedef DecisionTree<string,Crazy> CrazyDecisionTree; // check that DecisionTree is actually generic (as it pretends to be)
|
||||||
|
|
Loading…
Reference in New Issue