Added conversion to base BayesNet from derived (includes Symbolic from Gaussian)
parent
19d1514008
commit
6b5a385b7e
|
|
@ -74,6 +74,12 @@ public:
|
|||
/** Default constructor as an empty BayesNet */
|
||||
BayesNet() {};
|
||||
|
||||
/** convert from a derived type */
|
||||
template<class DERIVEDCONDITIONAL>
|
||||
BayesNet(const BayesNet<DERIVEDCONDITIONAL>& bn) {
|
||||
conditionals_.assign(bn.begin(), bn.end());
|
||||
}
|
||||
|
||||
/** BayesNet with 1 conditional */
|
||||
BayesNet(const sharedConditional& conditional) { push_back(conditional); }
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,6 @@ using namespace example;
|
|||
Key kx(size_t i) { return Symbol('x',i); }
|
||||
Key kl(size_t i) { return Symbol('l',i); }
|
||||
|
||||
//Symbol _B_('B', 0), _L_('L', 0);
|
||||
//IndexConditional::shared_ptr
|
||||
// B(new IndexConditional(_B_)),
|
||||
// L(new IndexConditional(_L_, _B_));
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST( SymbolicBayesNet, constructor )
|
||||
{
|
||||
|
|
@ -64,6 +59,18 @@ TEST( SymbolicBayesNet, constructor )
|
|||
CHECK(assert_equal(expected, actual));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST( SymbolicBayesNet, FromGaussian) {
|
||||
SymbolicBayesNet expected;
|
||||
expected.push_back(IndexConditional::shared_ptr(new IndexConditional(0, 1)));
|
||||
expected.push_back(IndexConditional::shared_ptr(new IndexConditional(1)));
|
||||
|
||||
GaussianBayesNet gbn = createSmallGaussianBayesNet();
|
||||
SymbolicBayesNet actual(gbn);
|
||||
|
||||
EXPECT(assert_equal(expected, actual));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue