import java.util.HashMap;
import java.util.Map;
import org.antlr.runtime.tree.CommonTree;
import edu.gmu.seor.prognos.unbbayesplugin.cps.CPSCompilerMain;
import edu.gmu.seor.prognos.unbbayesplugin.cps.Jama.Matrix;
import edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDBUnit;
import edu.gmu.seor.prognos.unbbayesplugin.cps.dmp.DirectMessagePassing;
public class UnscentedTransformation_Test extends Test{
public UnscentedTransformation_Test() {
// TODO Auto-generated constructor stub
}
public void Test1() {
//EQUATION.0.[DATA:+]
//EQUATION.0.1.[DATA:*]
//EQUATION.0.1.1.[DATA:-]
//EQUATION.0.1.1.1.[DATA:0.5]
//EQUATION.0.1.2.[DATA:MetaCancer]
//EQUATION.0.2.[DATA:NormalDist]
//EQUATION.0.2.1.[DATA:0]
//EQUATION.0.2.2.[DATA:1]
EDBUnit eq = new EDBUnit("EQUATION");
EDBUnit eq0 = eq.create("0", "+" );
EDBUnit eq01 = eq0.create("1", "*" );
EDBUnit eq011 = eq01.create("1", "-" );
EDBUnit eq0111 = eq011.create("1", "0.5" );
EDBUnit eq012 = eq01.create("2", "MetaCancer" );
EDBUnit eq02 = eq0.create("2", "NormalDist" );
EDBUnit eq021 = eq02.create("1", "0" );
EDBUnit eq022 = eq02.create("2", "1" );
eq.print("");
Matrix augMu = new Matrix(2,1);
Matrix augSigma = new Matrix(2,2);
double Q = 0;
augMu.set(0, 0, 30);
augMu.set(1, 0, 0);
augSigma.set(0, 0, 1);
augSigma.set(1, 1, 1);
Map<String, Integer> mapName = new HashMap<String, Integer>();
mapName.put("NormalDist", 1);
mapName.put("MetaCancer", 0);
DirectMessagePassing dmp = new DirectMessagePassing();
Matrix reM = dmp.mysut_wgn( eq, augMu, augSigma, Q, mapName );
//reM = [[-15.0], [1.2500000000000013]]
}
public void Test2() {
// Log( X, e ) + Root(Y, 2)
//EQUATION.0.[DATA:+]
//EQUATION.0.1.[DATA:Log]
//EQUATION.0.1.1.[DATA:X]
//EQUATION.0.1.2.[DATA:e]
//EQUATION.0.2.[DATA:Root]
//EQUATION.0.2.1.[DATA:Y]
//EQUATION.0.2.2.[DATA:2]
EDBUnit eq = new EDBUnit("EQUATION");
EDBUnit eq0 = eq.create("0", "+" );
EDBUnit eq01 = eq0.create("1", "Log" );
EDBUnit eq011 = eq01.create("1", "X" );
EDBUnit eq012 = eq01.create("2", "e" );
EDBUnit eq02 = eq0.create("2", "Root" );
EDBUnit eq021 = eq02.create("1", "Y" );
EDBUnit eq022 = eq02.create("2", "2" );
eq.print("");
Matrix augMu = new Matrix(2,1);
Matrix augSigma = new Matrix(2,2);
double Q = 5;
augMu.set(0, 0, 30);
augMu.set(1, 0, 10);
augSigma.set(0, 0, 1);
augSigma.set(1, 1, 1);
Map<String, Integer> mapName = new HashMap<String, Integer>();
mapName.put("X", 0);
mapName.put("Y", 1);
DirectMessagePassing dmp = new DirectMessagePassing();
Matrix reM = dmp.mysut_wgn( eq, augMu, augSigma, Q, mapName );
//reM = [[6.558941052940292], [5.026291847598541]]
}
public void Test3() {
String strEquation = "Log( X, e ) + Root(Y, 2);";
EDBUnit eq = new EDBUnit("EQUATION");
CPSCompilerMain.This().InitCompiler();
CommonTree ct = CPSCompilerMain.This().CompileScript(strEquation);
CPSCompilerMain.This().convertCommonTreeToEUnit(eq, ct, false, false);
eq.print("");
Matrix augMu = new Matrix(2,1);
Matrix augSigma = new Matrix(2,2);
double Q = 5;
augMu.set(0, 0, 30);
augMu.set(1, 0, 10);
augSigma.set(0, 0, 1);
augSigma.set(1, 1, 1);
Map<String, Integer> mapName = new HashMap<String, Integer>();
mapName.put("X", 0);
mapName.put("Y", 1);
DirectMessagePassing dmp = new DirectMessagePassing();
Matrix reM = dmp.mysut_wgn( eq, augMu, augSigma, Q, mapName );
reM.print(30, 15);
//reM = [[6.558941052940292], [5.026291847598541]]
}
public void Test4() {
String strEquation = "-X + Root(Y, 2);";
EDBUnit eq = new EDBUnit("EQUATION");
CPSCompilerMain.This().InitCompiler();
CommonTree ct = CPSCompilerMain.This().CompileScript(strEquation);
CPSCompilerMain.This().convertCommonTreeToEUnit(eq, ct, false, false);
eq.print("");
Matrix augMu = new Matrix(2,1);
Matrix augSigma = new Matrix(2,2);
double Q = 5;
augMu.set(0, 0, 30);
augMu.set(1, 0, 10);
augSigma.set(0, 0, 1);
augSigma.set(1, 1, 1);
Map<String, Integer> mapName = new HashMap<String, Integer>();
mapName.put("X", 0);
mapName.put("Y", 1);
DirectMessagePassing dmp = new DirectMessagePassing();
Matrix reM = dmp.mysut_wgn( eq, augMu, augSigma, Q, mapName );
reM.print(30, 15);
//reM = [[6.558941052940292], [5.026291847598541]]
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
UnscentedTransformation_Test UT = new UnscentedTransformation_Test();
//UT.Test1();
//UT.Test2();
//UT.Test3();
UT.Test4();
}
}