Package

Source Code of Continuous_DMP_Test


import unbbayes.util.Debug;
import edu.gmu.seor.prognos.unbbayesplugin.cps.CPSCompilerMain;
import edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDB;


public class Continuous_DMP_Test  extends Test{
  public Continuous_DMP_Test() { 
    //Debug.setDebug(true);
     //EDB.This().printSet(true);
  }
 
  String ComaNet = new String(
      "defineNode(MetaCancer, DescriptionMetaCancer);"+
        "{ defineState(Continuous);" +
        "p( MetaCancer ) = NormalDist( 30, 1 ); }" +
     
      "defineNode(SeriumCalcium, DescriptionSeriumCalcium);"+
      "{ defineState(Continuous);" +
      "p( SeriumCalcium | MetaCancer ) = -0.5*MetaCancer + NormalDist( 0, 1 ); }" +
    
      "defineNode(BrainTumor, DescriptionBrainTumor);"+
      "{ defineState(Continuous);" +
      "p( BrainTumor | MetaCancer ) = 2*MetaCancer + NormalDist( 5, 1 ); }" +
    
      "defineNode(Coma, DescriptionComa);"+
      "{ defineState(Continuous);" +
      "p( Coma | SeriumCalcium, BrainTumor ) = -2*SeriumCalcium + 1*BrainTumor + NormalDist( 0, 1 ); }" +
    
      "defineNode(SHeadaches, DescriptionBrainTumor);"+
      "{ defineState(Continuous);" +
      "p( SHeadaches | BrainTumor ) = 1*BrainTumor + NormalDist( 0, 0.5 ); }"  
  );
  
  public void test1() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
        cpsCompiler.compileComaNet +
                   "defineEvidence( Coma, 92.41 );"+
                  "defineEvidence( SHeadaches, 63.943 );"+
                   "run(DMP);" );
       
        //Comparison
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.MetaCancer.MSG.BEL.MU").getMatrixData()29.523034207857980 );   
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.MetaCancer.MSG.BEL.SIGMA").getMatrixData()0.254482325504114 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.SeriumCalcium.MSG.BEL.MU").getMatrixData(),  -14.352673158540613 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.SeriumCalcium.MSG.BEL.SIGMA").getMatrixData()0.270387188212737 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.BrainTumor.MSG.BEL.MU").getMatrixData()63.909060139385270 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.BrainTumor.MSG.BEL.SIGMA").getMatrixData()0.413532788895736 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.Coma.EVIDENCE").getData()92.41 );
    check( EDB.This().get("ROOT.ENGINES.DMP.NODES.SHeadaches.EVIDENCE").getData()63.943 );
    }
 
  public void test2() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
        cpsCompiler.compile( ComaNet +
                  "defineEvidence( MetaCancer, 33.33 );"+
                   "run(DMP);" );
    }
 
  public void test3() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
        cpsCompiler.compile( ComaNet +
                   "defineEvidence( SeriumCalcium, -16.555);"+
                   "run(DMP);" );
    }
 
  public void test4() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
        cpsCompiler.compile( ComaNet +
                   "defineEvidence( SeriumCalcium, -16.555);"+
                  "defineEvidence( BrainTumor, 63.943 );"+
                       "run(DMP);" );
    }
  
 
  public void test_final() { 
    //////test1();
    test2();
    test3();
    test4();
   }
 
  public void test_All() {
    test_final();
  }
 
  /**
   * @param args
   */
  public static void main(String[] args) {
    Continuous_DMP_Test t = new Continuous_DMP_Test();
    t.test_All();
  }

}
TOP

Related Classes of Continuous_DMP_Test

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.