import unbbayes.util.Debug;
import edu.gmu.seor.prognos.unbbayesplugin.cps.CPSCompilerMain;
import edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDB;
public class Hybrid_Looped_Test extends Test{
public Hybrid_Looped_Test() {
Debug.setDebug(true);
EDB.This().printSet(true);
}
/* % mk_hybridTest_1d2c_bnet creates an example CLG of polytree, in which one
% continuous node W has one discrete parent A, and two continuous
% parents X, and Y, shown as below:
%
% A (X)<-(Y)
% \ | /
% \ | /
% \| /
% (W)
%
%
% A is the discrete nodes.
% X, Y, W, are continuous nodes.
% W has one discrete parents and two continuous parents
% */
String mk_hybridTest_1d2c_connected_bnet = new String(
"defineNode(A, DescriptionA);"+
"{ defineState(Discrete, a1, a2);" +
"p( A ) = { a1:0.8; a2:0.2; } }" +
"defineNode(Y, DescriptionY);"+
"{ defineState(Continuous);" +
"p( Y ) = NormalDist( 3, 0.5 ); }" +
"defineNode(X, DescriptionX);"+
"{ defineState(Continuous);" +
"p( X | Y ) = 0.5 * Y + NormalDist( -5, 1 ); }" +
"defineNode(W, DescriptionW);"+
"{ defineState(Continuous);" +
"p( W | A, X, Y ) = if( A == a1 ){ X - 1.5*Y + NormalDist( 2, 1 ); } " +
" else if( A == a2 ){ 2*X+Y + NormalDist( -1, 0.5 ); } " +
"}" );
public void test6() {
CPSCompilerMain cpsCompiler = new CPSCompilerMain();
cpsCompiler.InitCompiler();
cpsCompiler.compile( mk_hybridTest_1d2c_connected_bnet +
"defineEvidence( W, 3 );"+
"run(DMP);" );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Y.BEL.MU").getMatrixData(), 1.2014636308259241 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Y.BEL.SIGMA").getMatrixData(), 0.3177504308442054 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.X.BEL.MU").getMatrixData(), -0.45887404150197497 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.X.BEL.SIGMA").getMatrixData(), 0.20098982321165715 );
}
public void test_final() {
test6();
}
public void test_All() {
test_final();
}
/**
* @param args
*/
public static void main(String[] args) {
Hybrid_Looped_Test t = new Hybrid_Looped_Test();
t.test6();
}
}