Example #1
0
void TestsPnlHigh::TestConditionalGaussianGetJPD()
{
    printf("TestConditionalGaussianGetJPD\n");

    BayesNet *net = SimpleCGM1();
    
    net->SetPGaussian("Cont0", "1.5 -0.5", "1.0 0.3 0.3 2.0", TokArr(), TokArr());
    net->SetPGaussian("Cont1", "0.0", "2.5", "1.0 3.0", "Tab0^State0");
    net->SetPGaussian("Cont1", "-1.5", "0.75", "0.5 2.5", "Tab0^State1");

    net->SetProperty("Inference", "naive");

    net->EditEvidence("Tab0^State0");
    net->GetJPD("Cont0");
    net->GetJPD("Cont1");
    net->GetJPD("Cont2");

    net->ClearEvid();

    Tok tok0("Cont0^Dim0^0.0");
    Tok tok1("Cont0^Dim1^0.0");

    TokIdNode *id0 = tok0.Node();
    TokIdNode *id1 = tok1.Node();

    bool is_int0 = id0->id[id0->id.size()-1].is_int; 
    bool is_int1 = id1->id[id1->id.size()-1].is_int;

    int int_id0 = id0->id[id0->id.size()-1].int_id;
    int int_id1 = id1->id[id1->id.size()-1].int_id;

    TokIdNode *id = net->Net().Token().Node(Tok("Cont0"))->v_next;
    TokIdNode *id2 = net->Net().Token().Node(Tok("Cont1"))->v_next;
    TokIdNode *id3 = net->Net().Token().Node(Tok("Cont2"))->v_next;
    TokIdNode *id4 = net->Net().Token().Node(Tok("Tab0"))->v_next;

    //TokIdNode *a1 = id->v_next;
    //TokIdNode *a2 = a1->h_next;

    net->EditEvidence("Cont0^Dim0^0.0 Cont0^Dim1^1.0");
    net->EditEvidence("Cont1^Dim0^0.0");
    net->EditEvidence("Cont2^Dim0^0.0");

    net->GetJPD("Tab0");

    delete net;
};  
Example #2
0
void TestsPnlHigh::TestCondGaussianGetMPE()
{
    printf("TestCondGaussianGetMPE\n");

    BayesNet *net = SimpleCGM1();
    //Cont0(3) Tab0(0)
    //  |      |
    //  \/    \/
    //   Cont1(1)
    //    |
    //    \/
    //   Cont2(2)

    net->SetPGaussian("Cont0", "1.5 -0.5", "1.0 0.3 0.3 2.0", TokArr(), TokArr());
    net->SetPGaussian("Cont1", "0.0", "2.5", "1.0 3.0", "Tab0^State0");
    net->SetPGaussian("Cont1", "-1.5", "0.75", "0.5 2.5", "Tab0^State1");

    net->SetProperty("Inference", "naive");

    net->EditEvidence("Tab0^State1");
    #ifndef PRINT_TestCondGaussianGetMPE
	net->GetMPE("Cont0");
	net->GetMPE("Cont1");
	net->GetMPE("Cont2");
    #else
	std::cout << String(net->GetMPE("Cont0")) << "\n";
	std::cout << String(net->GetMPE("Cont1")) << "\n";
	std::cout << String(net->GetMPE("Cont2")) << "\n";
    #endif

    net->ClearEvid();

    net->EditEvidence("Cont0^Dim0^0.0 Cont0^Dim1^1.0");
    net->EditEvidence("Cont1^Dim0^0.0");
    net->EditEvidence("Cont2^Dim0^0.0");

    #ifndef PRINT_TestCondGaussianGetMPE
	net->GetMPE("Tab0");
    #else
	std::cout << String(net->GetMPE("Tab0")) << "\n";
    #endif

    delete net;
	std::cout << "TestCondGaussianGetMPE is completed successfully" << std::endl;

};
Example #3
0
void TestsPnlHigh::Test2EditEvidence()
{
    BayesNet *net = VerySimpleMultivariateGaussianModel();

    net->EditEvidence("NodeB^dim1^0.0 NodeB^dim2^1.0");
    net->EditEvidence("NodeA^dim1^0.7 NodeA^dim2^1.7");
    net->EditEvidence("NodeC^dim1^0.7 NodeC^dim2^1.7");

    net->ClearEvid();

    net->EditEvidence("NodeB^dim1^0.0 NodeB^dim2^1.0");
    net->EditEvidence("NodeA^dim1^0.7 NodeA^dim2^1.7");
    net->EditEvidence("NodeC^dim1^0.7 NodeC^dim2^1.7");

    delete net;

    net = VerySimpleGaussianModel();

    net->EditEvidence("NodeB^dim1^0.0");
    net->EditEvidence("NodeA^dim1^0.7");
    net->EditEvidence("NodeC^dim1^1.4");

    delete net;
};