import unbbayes.util.Debug;
import edu.gmu.seor.prognos.unbbayesplugin.cps.CPSCompilerMain;
import edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDB;
public class Hybrid_Test_V3 extends Test{
public Hybrid_Test_V3() {
Debug.setDebug(true);
}
/* %
%
% T o---- K
% / \ / \
% o o o (Y)
% (Y)---o(W)
% | |
% | |
% o o
% (L) (Z)
%
%
% */
String mk_2d4c_bnet_Connected = new String(
"defineNode(K, DescriptionK);"+
"{ defineState(Discrete, k1, k2);" +
"p( K ) = { k1:0.8; k2:0.2; } }" +
"defineNode(T, DescriptionT);"+
"{ defineState(Discrete, t1, t2);" +
"p( T | K ) = if( K == k1 ) { t1:0.3; t2:0.7; }" +
"else if( K == k2 ) { t1:0.5; t2:0.5; } " +
" }" +
"defineNode(Y, DescriptionY);"+
"{ defineState(Continuous);" +
"p( Y | T, K ) = if( T == t1 && K == k1 ) { NormalDist(-1, 1); }" +
"else if( T == t1 && K == k2 ) { NormalDist(1, 1); } " +
"else if( T == t2 && K == k1 ) { NormalDist(3, 1); } " +
"else if( T == t2 && K == k2 ) { NormalDist(4, 1); } " +
"}" +
"defineNode(W, DescriptionW);"+
"{ defineState(Continuous);" +
"p( W | T, K, Y ) = if( T == t1 && K == k1 ){ 1*Y + NormalDist(2,1); } " +
"else if( T == t1 && K == k2 ){ 1*Y + NormalDist(-2,1); } " +
"else if( T == t2 && K == k1 ){ 1*Y + NormalDist(1,1); } " +
"else if( T == t2 && K == k2 ){ 1*Y + NormalDist(0,1); } " +
"}" +
"defineNode(Z, DescriptionZ);"+
"{ defineState(Continuous);" +
"p( Z | W ) = 0.5*W + NormalDist( 5, 1 ); " +
"}" +
"defineNode(L, DescriptionL);"+
"{ defineState(Continuous);" +
"p( L | Y ) = 0.5*Y + NormalDist( 0, 1 ); " +
"}"
);
public void mk_2d4c_bnet_Connected_test() {
CPSCompilerMain cpsCompiler = new CPSCompilerMain();
cpsCompiler.InitCompiler();
cpsCompiler.compile( mk_2d4c_bnet_Connected +
// "defineEvidence( L, 2 );"+
"defineEvidence( K, k1 );"+
"run(DMP);" );
//Comparison
/* check( EDB.This().get("ROOT.ENGINES.DMP.NODES.T.BEL").getNext("t1").getData(), 0.412736);
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.K.BEL").getNext("k1").getData(), 0.898263);
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Y.BEL.MU").getMatrixData(), -0.050799 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Y.BEL.SIGMA").getMatrixData(), 0.743017 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Z.BEL.MU").getMatrixData(), 1.0 );
check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Z.BEL.SIGMA").getMatrixData(), 1.0);
*/ }
public void test_final() {
mk_2d4c_bnet_Connected_test();
}
public void test_All() {
test_final();
}
/**
* @param args
*/
public static void main(String[] args) {
Hybrid_Test_V3 t = new Hybrid_Test_V3();
t.test_All();
}
}